Forum Moderators: phranque
Be aware however, that it is up to the client, his/her security software, and any intervening corporate, ISP, and/or network caching proxies whether an HTTP_REFERER header is sent. So the solution must be designed to behave correctly in the even that the HTTP referrer is blank.
Jim
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?domain1.com(/)?.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?domain2.com(/)?.*$ [NC]
ErrorDocument 404 [mydomain.com...]
RewriteRule .* [mydomain.com...] [R]
this would do a rewrite to fake404.html when the 404 comes from domain1.com or domain2.com
if not it will go to real404.html
Is this what you mean, in the right syntax?
I am a rookie so I need some help on the correct syntax.
Thanks a lot.
.
Check exactly what jd said, word for word, then follow the instructions in that order.
.
>> declare a "fake" ErrorDocument for 404 errors <<
ErrorDocument 404 /idonotexist.html
.
>> use mod_rewrite to rewrite requests for that fake 404 error document to either the "special" 404 error document <<
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?someothersite\.com [NC]
RewriteRule idonotexist.html /errors/errorpage1.html [L]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?thatothersite\.net [NC]
RewriteRule idonotexist.html /errors/errorpage2.html [L]
.
>> or to the "normal" 404 error document, based on the requesting HTTP_REFERER <<
RewriteRule idonotexist.html /errors/errorpagemain.html [L]
.
The above is rough untested code and does NOT explicitly cater for blank referrers.
I may have missed other things too. It is given as a starting experimental point for you.
You will learn a lot more fiddling with this code yourself; sometimes seemingly endless hours of frustration until you suddenly realise you overlooked something basic.
.
I expect that jd has a better way of tackling this than my example.