Forum Moderators: phranque
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://www.example.com.*$ [NC]
RewriteRule .* - [F,L]
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www\.)?example\.com/ [NC]
RewriteRule !^path-to-custom-403-page\.html - [F]
Also note that [L] used with [F] is redundant, so I removed the [L].
[added] Another alternative is to *not* use a custom error page for 403 errors, but instead use the server's default error message by removing any/all "ErrorDocument 403" declaration directives from your server config and .htaccess files. [/added]
Jim
It may be a s simple as needing to add:
Options +FollowSymLinks
However, if that's the case, then that means you likely don't have any other rules already in place, and that in turn implies that you likely have several domain- and URL-canonicalization 'holes' in your site, making it prone to duplicate-content problems...
Jim
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?example\.com/ [NC]
RewriteRule .* - [F]
There are other rules in place but I can try adding Options +FollowSymLinks to this section. The site doesn't have any duplicate content problems although I've "been there ~ done that" a couple of years ago and know full well what a pain that is.
I may not get back to this for a few hours. I just got home from work and have this unrelenting need to sleep. Thanks again.
Do take a look at your server error log file.
www and non-www
- index name vs. /
- appended port numbers
By the way, the log files were fine. I just need to find a better product to open and read them with. The '500' errors weren't showing in the error logs at all, I thought for sure that they should show there at the same time I could see them in the latest visitors report. I need to have another 500 error to occur so I know for sure.
Until I, as a malicious competitor, go out and get lots of links for you that include them... Try typing http://www.google.com:443/ into your address bar, for example.
> I've decided to just drop this project for now.
:( :( :(
> It may have been just a one or two day flood of visitors from the useless site since I haven't seen any of them today.
The same code technique can be used to deal with log spammers, and the fact that you're having any trouble at all with it is in itself a good reason to continue debugging. It would be good to find out why something so trivial doesnt work, as it may point to a deeper (i.e. more important) problem.
> I've got a feeling that the files from yesterday are lost forever.
> I need to have another 500 error to occur so I know for sure.
Neither of these is much of a problem... Simply put the 'bad code' back on the server and test again.
If the idea of intentionally putting known-bad code on your server tends to give you the heebie-jeebies, you can always prefix any 'suspect' rule you want to test with a RewriteCond that only allows the rule to run if the request comes from you (i.e. from your own workstation's IP address or a subnet that includes, say, 256 addresses):
RewriteCond %{REMOTE_ADDR} =123.45.67.89
-or-
RewriteCond %{REMOTE_ADDR} ^123\.45\.67\.
Note that adding these safeguards protects only against rule execution errors. If there is a syntax error in the code, then it will still affect all users.
Jim
The idea of using my own IP for testing is great! However, I plan to do further testing on another one of my sites that doesn't get much traffic so I won't have to wade through so much to see the results. I've bookmarked this thread.