Forum Moderators: phranque
The problem I'm facing is that starting recently, a sex related domain has been showing up big time in our referral logs. The referral URL itself is some strange cgi redirect script I can't make heads or tails from (redirects to a 404 page), and it's obvious they're not sending actual visitors to my site. I suspect they may simply be hot linking or accessing some non html files on our server, jacking up the referral logs in the process. Using mod rewrite would seem to be the only solution, as something like IP tables blocks the domain itself, but not traffic redirected from and not necessarily originating from the offending domain (referrals).
Thanks much.
In a mod_rewrite/regular expressions context, an unescaped period means "any single character," so yes, you should precede periods in domain names, IP addresses, and file extensions with a backslash.
Ref: Regular expressions tutorial [etext.lib.virginia.edu]
Also, you don't need an "L" in your [F,L] flag - "L" is built into "F".
Ref: Apache mod_rewrite [httpd.apache.org]
Jim
RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} xxx\.com
RewriteCond %{HTTP_REFERER} anotherdomain\.com
RewriteRule .* - [F]
Are there any "flags" I need to add to the end of the two lines containing the domains, like [NC] or [OR]? I've seen them in documentations, but can't figure out when they're needed, such as in this case.
Thanks for the help.
Yes, you do need to ad [OR} after the first line, allowing a space after the expression, ie:
RewriteCond %{HTTP_REFERER} xxx\.com [OR]
RewriteCond %{HTTP_REFERER} anotherdomain\.com
RewriteRule .* - [F]
Also, if there is a possibility that the referer will have some uppercase letters in it, add NC to the switch, as in [NC,OR]
I hope this helps
Wiz
<Limit GET POST>
Order Allow,Deny
Allow from all
</Limit>
rewriteEngine on
Options +FollowSymlinks
rewriteCond %{HTTP_REFERER} offendingsite\.com
rewriteRule .* - [F]
ErrorDocument 403 [mysite.com...]
When I test by clicking the link on the offending site, I get this error message:
"Redirection limit for this URL exceeded. Unable to load the requested page. This may be caused by cookies that are blocked."
I'm thinking it doesn't have anything to do with cookies, and is instead related to my coding. Oops. Any advice?