Forum Moderators: DixonJones

Message Too Old, No Replies

htaccess file and custom error page

Trouble shooting

         

helleborine

3:52 am on Jan 29, 2005 (gmt 0)

10+ Year Member



Hi,

I want to show custom 404 and 403 pages.

It works for the 404 page, but not for the 403 page.

This is the code in my .htacesss file:

ErrorDocument 403 /error403.html
ErrorDocument 404 /error404.html

<Files 403.shtml>
order allow,deny
allow from all
</Files>

deny from 12.101.152.#*$!
deny from 12.147.139.xxx
etc.

The message they get is this:

Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Apache/1.3.33 Server at www.mydomain.com Port 80

Thanks ahead!

jdMorgan

4:43 am on Jan 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need to allow everyone to access error403.html; otherwise, they'll get a second 403 trying to view your custom error page, and another 403 because of that, and so on...

Jim

helleborine

4:50 am on Jan 29, 2005 (gmt 0)

10+ Year Member



How do I do that? I don't really understand the code on my own page, I just cut and pasted from a web site explaining how to have custom error pages...

jdMorgan

5:21 am on Jan 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I don't really understand the code on my own page

Start here: Apache mod_access [httpd.apache.org].

(I'd do you a disservice by giving you yet more code that you don't understand...)

Jim

helleborine

5:38 am on Jan 29, 2005 (gmt 0)

10+ Year Member



Thanks for the reference.

Would this work?

ErrorDocument 403 /error403.html
ErrorDocument 404 /error404.html

***added this***
<Files error403.html>
Allow from all
</Files>
****************

<Files 403.shtml>
order allow,deny
allow from all
</Files>

deny from 12.101.152.#*$!
deny from 12.147.139.xxx
etc.

jdMorgan

6:06 am on Jan 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like you're on the right track. I think the main problem is that the code you posted has a <Files> filename that does not match your ErrorDocument declaration.

Another way to do it is:


ErrorDocument 403 /error403.html
ErrorDocument 404 /error404.html
#
SetEnvIf Request_URI "/error40[34]\.html$" allowit
SetEnvIf Request_URI "^/robots.\txt$" allowit
Order Deny,Allow
Deny from 12.101.152.***
Deny from 12.147.139.***
Allow from allowit

This allows universal access to your 403, 404, and robots.txt pages, which I recommend.

It might take some very careful reading of the mod_access Order directive documentation to see how this works, but it's similar to what I use on my sites.

Jim

helleborine

12:03 pm on Jan 29, 2005 (gmt 0)

10+ Year Member



Thank you so much.

Now the document looks like this:

ErrorDocument 403 /error403.html
ErrorDocument 404 /error404.html
#
SetEnvIf Request_URI "/error403\.html$" allowit
SetEnvIf Request_URI "/error404\.html$" allowit
SetEnvIf Request_URI "^/robots.\txt$" allowit
Order Deny,Allow

deny from 12.101.152.#*$!
deny from 12.147.139.xx

Allow from allowit

Now, I'll just wait and see if my proxy/anonymizer-using troll brigade complains... ;-)