Re: Htaccess / regex / php I dont know why it won't work
| From: | affixcom | Date: | Tue, 02 Oct 2001 19:35:40 +0000 |
| Subject: | Re: 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-69631@lists.php.net to get a copy of this message | ||
Thanks,
I spent 2 days trying everything, and since I am not an expert on regex (do
that that just for fun), I though my script was bad. I'll check with my
hosting company if I can overrule the httpd.conf. I checked on phpinfo() and
mod_rewrite is loaded
Gab
----- Original Message -----
From: "Maxim Maletsky (PHPBeginner.com)" <php-general@phpbeginner.com>
To: "'affixcom'" <affixcom@yahoo.com>; <php-general@lists.php.net>
Sent: Tuesday, October 02, 2001 3:10 PM
Subject: RE: [PHP] Htaccess / regex / php I dont know why it won't work
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net