htaccess redirect to file based on referrer

by 20 replies
34
how do I redirect all traffic to a specific file in my html directory based on referrer with .htaccess?

I've tried various lines and I can't get it to work.
#programming #based #file #htaccess #redirect #referrer
  • It is possible although I am not sure what the use is that you are trying to make of .htaccess for redirectional purposes.
  • I use a site called corz.org for a lot of htaccess tips (no affiliation).
  • In the example below, we look for referer's from somesite.com and then redirect them to a page on your site called yoursite.html.

    Code:
    RewriteCond %{http_referer} ^http://([^.]+.)*(somesite).com
    RewriteRule ^$ yoursite.html [R=302,L]
    Please note for this to work you will need to have permission from your hosting company to use directives from the mod_rewrite module.

    Hope this helps...
    • [1] reply
    • -- the above syntax is not working



      Im trying to redirect based on if a referrer contains a certain string
      • [1] reply
  • yea ok I thought it was a problem with my server, but I just tried it on 3 different servers and I am getting the same error in firefox.
  • Yeah! It works! Thanks very much.
    • [1] reply
    • Hi swick,

      I suggest u gud redirection and 404 solving tool, if solve ur problem

      htaccessredirect.net

      Free .htaccess Redirect Generator


      Enjoy!!!
      • [1] reply

Next Topics on Trending Feed