Perl 403 HTTP Response
I have a handler set up in apache for html files.
I want this handler to return a 403 Forbidden error for certain IP addresses. How do I return a 403 header in perl. If i just do this Code:
print "HTTP/1.1 403 Forbidden\n\n"; Quote:
Am I being thick, or am I just not supposed to do it like this. Cheers |
You can't do exactly what you want in perl, but you can make it look like you have.
It's apache that generally returns any error codes, and since the script is obviously executing, it won't return the error you want. Either use a .htaccess to restrict access from those IP's, or make your script return a page that's exactly the same as apache's 403 if the remote_addr is one of the IP's you want to restrict. |
Cheers,
So I could do this in Apache Code:
Deny from 255.255.255.255 |
Yes, by putting the Directives in a .htaccess file in (or above) the directory you want to protect, which is read by Apache for every request so there's no need to restart at all.
|
that would mean putting the .htaccess file on every site.
I want to block the ip for all site on the machine. |
All times are GMT -5. The time now is 12:35 PM. |