Forum Moderators: open

Message Too Old, No Replies

need help with 403 custom page not working in .htaccess

I included an ErrorDocument 403 custom page but I get error message

         

Wizcrafts

4:06 am on May 26, 2003 (gmt 0)

10+ Year Member



I want to add a custom 403 access forbidden page to my website, so I created such a page, named 403.html and placed it in my "includes" directory. I typed this into my .htaccess, in my root folder: ErrorDocument 403 /includes/403.html

When I try to access a forbidden page using Wannabrowser with a blocked UA, I see my Host's generic Apache 403 page, with the addition at the bottom that a call to to custom ErrorDocument created an error. Of course no help is provided about this error. I have CHMODed the file to 744 as required to parse the SSI directive, with XBitHack On. I have commented out the SSI hitcounter call to no avail. I have copied and CHMODed the file to the root, with no affect. It always creates an error at the bottom of the Apache 403 Forbidden message.

I also have a custom 404, in the same directory, which works perfectly (at 644).

Below are the contents of the failed 403 page. I apologize in advance for the length of the post.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>403 Access Denied</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="robots" content="noindex,nofollow,noarchive">
<style type="text/css">
<!--
(SNIP)
-->
</style>
<base href="http://www.wizcrafts.net">
</head>
<body>
<h1 class="c">ACCESS DENIED!</h1>
<h3>Your access to our website has been blocked for one or more of the following reasons:</h3>
<ol>
<li>You have attempted to view a file or directory that is marked off-limits to the public</li>
<li>Your User-Agent is on our list of banned email harvester bots (Go Away!)</li>
<li>You are using a website downloader program that we have prohibited for bandwidth or copyright reasons</li>
<li>Your IP address is blacklisted, or is part of a block of blacklisted IP addresses, usually of spammer-friendly ISPs</li>
<li>You are, or you sent an indexing spider that we do not want to traverse or index our website</li>
</ol>

(Big text SNIP)

<hr>
<address>Wizcrafts Computer Services &nbsp; &copy; 2000-2003 <a href="http://www.wizcrafts.net/contact-info.html" title="Bot Trap! DO NOT click this link!"></a></address>
<!--#include virtual="/cgi-bin/MKCounter.cgi?id=403&hidden=0&count=1&log=1"-->
</body></html>

I have had to turn this line off in .htaccess for now. Any assistace will be appreciated.

jdMorgan

5:26 am on May 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wizcrafts,

The problem is likely to be in your .htaccess file, specifically in the RewriteRule(s) which invoke(s) the 403.

Since you are calling a custom 403 page, and it in turn is calling several includes, all of those files must be allowed to be accessed, regardless of the user-agent, IP address, etc. Otherwise, you end up in a 403-Forbidden loop, since access to these files themselves is also forbidden.

A simple example would be:


RewriteCond %{HTTP_USER_AGENT} ^Indy.Library [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget
RewriteRule !^(includes/403\.html¦cgi-bin/MKCounter\.cgi¦robots\.txt) - [F]

This code blocks two of our favorites, but allows unrestricted access to your 403 page, your counter, and your robots.txt file.

Note that "¦" characters get modified in posts on this board - change them to solid vertical pipe characters before use.

HTH,
Jim

Wizcrafts

9:58 am on May 26, 2003 (gmt 0)

10+ Year Member



Thanks again JD for setting me straight. I suspected that the problem was on my rewrite line and you confirmed it. However, I never would have grokked that I would need to allow all those additional files on the same rule line.

I just added the Rewrite rule you supplied and it works perfectly. Thanks again.

Wiz

wilderness

3:09 pm on May 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Jim
I surely hope you get commission on all these responses :)

RewriteCond %{HTTP_USER_AGENT} ^Indy.Library [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget
RewriteRule!^(includes/403\.html¦cgi-bin/MKCounter\.cgi¦robots\.txt) - [F]

I don't use an error page. Rather the standard server/browser default.
Would the following be correct if I desired the 403's to allow viewing of robots?

RewriteCond %{HTTP_USER_AGENT} ^Indy.Library [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget
RewriteRule!^(includes/403¦cgi-bin/MKCounter\.cgi¦robots\.txt) - [F]

TIA
Don

Wizcrafts

3:57 pm on May 26, 2003 (gmt 0)

10+ Year Member



Don;
Those paths are specific to my server, so the only part of use to you is the "robots\.txt" which I think would be written: RewriteRule!^ robots\.txt - [F].
You shouldn't need the parenthesis around the single filename.

Correct me if I am wrong.

I once thought I was wrong, but I was mistaken!

Wiz

Wizcrafts

3:59 pm on May 26, 2003 (gmt 0)

10+ Year Member



Why does the forum's software remove white space before an exclamation mark and change solid pipes into broken pipes?

Does anybody know and can the coding be adjusted to display literally as typed?

wilderness

4:54 pm on May 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



RewriteCond %{HTTP_USER_AGENT} ^Indy.Library [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget
RewriteRule!^(includes/403¦cgi-bin/MKCounter\.cgi¦robots\.txt) - [F]

Wiz
So is should the lines I desire read:
RewriteCond %{HTTP_USER_AGENT} ^Indy.Library [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget
RewriteRule!^(403¦robots\.txt) - [F]

Which would hopefully allow 403's to read robots?

coding be adjusted to display literally as typed?

It's something with software used for this forum and the options of styles.
Sorry I can't provide a URL however one can only assume if the configurations were an option it would have been resolved long ago.

at times a space is also omitted between }and ^.

Don

jdMorgan

5:08 pm on May 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry for the disconnect - It's defrag day... Buncha machines to do here...

Don,

You don't need the "403¦" in this line unless you have a custom 403 error page named "403" with no file extension.
RewriteRule !^(403¦robots\.txt) - [F]

All you need is:
RewriteRule !^robots\.txt$ - [F]

You can get a space before "!" to stay in your posts if you type TWO spaces.

Jim

Wizcrafts

5:34 pm on May 26, 2003 (gmt 0)

10+ Year Member




RewriteRule!^robots\.txt$ - [F]

Jim;
See how close I came to nailing that code? All I left out was the closing dollar sign after .txt. I'm learning a lot here. Thx again.
Wiz
PS: I had to use PRE tags in the quote to creates that space before!