Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2006
    Thanked 0 Times in 0 Posts

    using %{REFERER} in htaccess

    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?


  2. #2
    Regular Coder
    Join Date
    Oct 2004
    Thanked 26 Times in 26 Posts
    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts