RE: [PHP] Htaccess / regex / php I dont know why it won't work
| From: | Maxim Maletsky \(PHPBeginner.com\) | Date: | Tue, 02 Oct 2001 19:10:48 +0000 |
| Subject: | RE: [PHP] Htaccess / regex / php I dont know why it won't work | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-69622@lists.php.net to get a copy of this message | ||
I think this was supposed to work:
.htaccess
RewriteEngine On
RewriteRule ^(.*)\.zajfe\.org$ redirect.php?url=$1 [L]
Are you sure it doesn't? If it doesn't then meas they
1. don't have mod_rewrite (phphinfo shows you the modules loaded)
2. don't allow .htaccess to override httpd.conf rules.
Also read about mod_rewrite, right in the manual there are a few
examples to do what you need. Always if you have it loaded.
Maxim Maletsky
www.PHPBeginner.com
-----Original Message-----
From: affixcom [mailto:affixcom@yahoo.com]
Sent: martedì 2 ottobre 2001 20.54
To: php-general@lists.php.net
Subject: [PHP] Htaccess / regex / php I dont know why it won't work
Hi,
I have a website hosted on a cobalt server with my own domain, but not
my own IP. I have a full access to my root web, but not higher (means
can't change any *.conf files). My domain is "wildcarded" I want to be
able to redirect based on the entry, IE if a user types
http://hello.mydomain.com he will go to http://mydomain.com/hello=20 if
a user types http://another.mydomain.com he will go to
http://mydomain.com/another=20
The redirect method of apache doesn't work because I leanred that that
is based on an absolute path from the server I tried php scripts that
read the subdomain and use it in the header function but it won't work.
I came to the conclusion after a lot of tests that rewriterule from the
htaccess is the the best.
htaccess script: (doesn't work)
RewriteEngine On
RewriteRule ^(.*)\.zajfe\.org$ redirect.php?url=$1 [L]
connected to the page redirect.php where
<?header("location:http://www.zajfe.org/$url");?>
PHP script: (doesn't work)
<?
$domain = "yourdomain.com";
$default_page = "main.shtml";
$underdomaene = $HTTP_HOST;
$underdomaene = eregi_replace("\.".$domain, "", $underdomaene);
$underdomaene = eregi_replace("www\.", "", $underdomaene); $underdomaene
= strtolower($underdomaene); if (is_dir("$DOCUMENT_ROOT/$underdomaene"))
{
header("Location: http://$domain/$underdomaene");
}
else {
if (!$REQUEST_URI || $REQUEST_URI == "/") {
include("$DOCUMENT_ROOT/$default_page");
}
else {
header("Location: http://$domain$REQUEST_URI");
}
}
?>
I am open to ANY suggestion, CGI / ASP / PHP / SSI (it is all on the
server), I want it to work
Thanks
Gab