cancel
Showing results for 
Search instead for 
Did you mean: 

any .htaccess experts here?

IanSn
Rising Star
Posts: 506
Thanks: 21
Registered: ‎25-09-2011

any .htaccess experts here?

[wasn't sure where to put this - its not about a PN service so figured I'd pop it in here - even though its not a Windows issue either...]
------
Can't figure out why the code below is producing a 500 code and not a 403 (as it should) when the offending referrer visits the website.
* (This is not an overall 500 when loading the site. I mean the code that only the offending visitor sees.)
RewriteEngine on
RewriteCond %{HTTP_REFERER} unwantedreferrer\.com [NC]
RewriteRule .* -
Have tried with
Options +FollowSymlinks
added and removed. Same result.
This is on a sub-domain. Have also tried including the .htaccess rewrite on the main domain as well. Same results.
I had other rewrite commands already used without the +FollowSymlinks enabled, so not sure that it was necessary at all. Nevertheless, getting wrong code returned here anyway.
Probably need to chat to ISP about this, maybe its just firing the wrong code (it is actually blocking the visitor, so not major problem), but just wondered if there were any bright sparks on here before I do that!
Btw, yes, have checked Apache site. Could be missing something, but didn't find much.
9 REPLIES 9
spraxyt
Superuser
Superuser
Posts: 10,063
Thanks: 1,369
Fixes: 75
Registered: ‎06-04-2007

Re: any .htaccess experts here?

Your .htaccess entry seems OK to me with/without Options +FollowSymlinks depending on what your service needs. I'd expect to see a 403 Forbidden response. Is there anything in the server error log which explains the 500 Server Error?
Edit: I tried your code (adapted for my referrer) on Plusnet Homepages and was served a 403 Forbidden page as expected.
David
IanSn
Rising Star
Posts: 506
Thanks: 21
Registered: ‎25-09-2011

Re: any .htaccess experts here?


There hasn't been anything showing in the error log for a while. That's been the other odd thing. Blank white page.
But it has started producing logs again tonight - a few 403s reported from blocked IPs.
Looks like I'll have to wait for the offending referrers to return and keep checking the error logs!
I'll post back if anything shows up.
Thanks
avatastic
Community Veteran
Posts: 1,136
Thanks: 2
Registered: ‎30-07-2007

Re: any .htaccess experts here?

Has .htaccess worked before for you? It could be the server is not configured to allow what you're trying to use it for.
http://httpd.apache.org/docs/current/mod/core.html#allowoverride
F9 member since 4 Sep 1999
F9 ADSL customer since 27 Aug 2004
DLM manages your line the same way DRM manages your rights.
Look at all the pretty graphs! (now with uptime logging!)
IanSn
Rising Star
Posts: 506
Thanks: 21
Registered: ‎25-09-2011

Re: any .htaccess experts here?

@avatastic
Yes, have had several 'rewrites' in operation for yonks.
I'm now waiting to see if error logs will give a clue next time it crops up.
After that probably contact host. Could be something else about directives.
(There was a funny glitch on the server a couple of years ago where it was producing 404s instead of 403s which was recified at their end - no idea how that works!...)
spraxyt
Superuser
Superuser
Posts: 10,063
Thanks: 1,369
Fixes: 75
Registered: ‎06-04-2007

Re: any .htaccess experts here?

Does the Web server have read access to the 403 error page?
David
IanSn
Rising Star
Posts: 506
Thanks: 21
Registered: ‎25-09-2011

Re: any .htaccess experts here?

Yes. And it works.
Still wating for one of the offending referrers to hit again. Last week I was inundated.
They wont come now I want them to! Maybe they got the message... job done.
(Doubt that actually - these were obviously zombied from all over the place - most Brazil. They'll be back alright.)
But stil want to know what's wrong with it.
IanSn
Rising Star
Posts: 506
Thanks: 21
Registered: ‎25-09-2011

Re: any .htaccess experts here?

OK, caught one. The server error log is producing the expected [error] notification as if it were a 403. It all looks as it should.
But the logs are showing it as 500.
I presume this means the 500.shtml file is being used.
I've added a bit to the 500 file to say its either a server error or not permitted!
Guess I'll drop a line to the host. Must be something there  Undecided
spraxyt
Superuser
Superuser
Posts: 10,063
Thanks: 1,369
Fixes: 75
Registered: ‎06-04-2007

Re: any .htaccess experts here?

Presumably pages for errors other than 403 Forbidden display correctly?
David
IanSn
Rising Star
Posts: 506
Thanks: 21
Registered: ‎25-09-2011

Re: any .htaccess experts here?

Yes, indeed.
And 403 displays fine for 'deny from IP'.
A far as the error log shows this rewrite should be displaying 403, too.
Perplexing why it doesn't...
edit --
perhaps I could fake a referrer and see what does actually happen...