Forum Moderators: phranque

Message Too Old, No Replies

Redirect external referrals only

to a specific directory

         

cfe_admin

9:28 pm on Feb 16, 2007 (gmt 0)

10+ Year Member



I'm trying to use mod rewrite to redirect anyone referred from a different site for a specific directory. So, for example, from:

[mydomain.com...]

to:

[mydomain.com...]

This needs to happen ONLY for people directed from off site. I tried modifying some hot-link-blocking code to accomplish this as follows:

RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\\.)?mydomain.com/.*$ [NC]
RewriteRule .*thisfolder.* [mydomain.com...] [R,L]

No luck, any thoughts? Thanks!

jdMorgan

3:40 pm on Feb 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The code contained several errors that may have prevented it from working, as well as several inefficiencies. This is the danger of using code that you've copied and don't understand.

Try:


RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC]
RewriteRule thisfolder http://www.example.com/tohere.php [R,L]

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim