Forum Moderators: phranque
This is what we are trying to do:
If the HTTP_Referer of a request contains a string "badstring.com" we want to redirect the request to a page "go-fishing.htm". Our set up works - but the request returns a error page that (correctly) says "Document has moved here: http://example.com/go-fishing.htm". But we can't redirect them directly - without returning the error page.
Another problem with our code is: we have to specify a url but we want to specify a partial string (without http or tld).
Code we currently use:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http(s)?://([a-z0-9-]+\.)*badstring.com/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://([a-z0-9-]+\.)*badstring.com/.*$ [NC]
RewriteRule /* http://%{HTTP_HOST}/go-fishing.htm [R,L]
Could someone please give me a code that works like i described above (forcing direct redirection)? BTW: the site runs on pure apache.
[edited by: jdMorgan at 3:01 pm (utc) on Oct. 25, 2003]
[edit reason] Examplified URLs per author's request [/edit]
RewriteEngine on
RewriteCond %{HTTP_REFERER} .*badstring.*
RewriteRule .* http://example.com/go-fishing.html [L]
Thanks for all the masses of answers and contributions to this great thread.
:)
[edited by: jdMorgan at 3:01 pm (utc) on Oct. 25, 2003]
[edit reason] Examplified URL per author's request [/edit]