fnsnoop
01-06-2006, 07:13 PM
I am trying to do a
Redirect permanent /index.php http://www.something.com/test/index.php
it works fine, but i want to replace http://www.something.com with %{HTTP_REFERER} so it can change where to go based on where they came from.
any ideas?
Alex
schleppel
01-06-2006, 08:21 PM
I'm not sure what you're trying to do, replacing http://www.something.com with
%{HTTP_REFERER} doesn't seem a good idea to me, personally, are you sure you want to do that?
This code should get you started anyway, (if you have mod_rewrite on your server and enabled):
RewriteEngine On
# if %{HTTP_REFERER} isn't empty
RewriteCond %{HTTP_REFERER} !^$
# redirect some where based on it
RewriteRule ^index\.php$ %{HTTP_REFERER}/test/index.php [R,L]
# if %{HTTP_REFERER} was empty go to this default page
RewriteRule ^index\.php$ http://default.tld/page.ext [R,L]
index\.php is the page to redirect if accessed. ("." [periods] are escaped with "\" [backslash])
http://default.tld/page.ext is the default page to redirect to.
%{HTTP_REFERER}/test/index.php is the place to redirect to based on the referer.