Jump to content

Recommended Posts

Posted

I'm trying to setup my .htaccess file to use custom error documents.

The problem is that if I put:

 

ErrorDocument 403 *****/403.html

 

it works fine, but

 

ErrorDocument 403 /403.html

 

does not work... Why?

 

Thanks

Posted

Just a guess .. but I would suspect the reason it does not work is that /403.html is saying to go to your root directory to find the file 403.html -- but obviously it is not finding the '403.html' file there.

 

Remember that your web site is actually located at: /home/{username}/public_html

This is is usually referred to as your document root.

 

So, if you really want to reference your error file as /403.html -- you're going to have to move it up to your /home directory -- or change your .htaccess file to read:

 

ErrorDocument 403 /home/{username}/public_html/403.html

 

Does that make any sense?

kw

Posted

If you look in the error log for your site you'll find the actual pathname that wasn't found.

(In your cPanel, look under Stats.) That will tell you where to put the error document.

For example:

 

[sun Jun 15 01:50:47 2003] [error] [client 203.203.132.234] File does not exist:

/home/something/public_html/404.shtml

 

You may also have to check the server-wide error log at /usr/local/apache/logs/error_log :

 

[sun Jun 15 01:49:49 2003] [error] [client 66.11.162.123] File does not exist:

/usr/local/apache/htdocs/404.shtml

 

I found that this path worked for a file located in /home/idallen/public_html/404.txt :

 

ErrorDocument 404 /~idallen/404.txt

Posted

Strangely, /home/something/public_html/404.html did not work (i had already tried that one), but /~username/404.html does.. I don't get it but at least it works now! Thanks

Posted
Strangely, /home/something/public_html/404.html did not work (i had already tried that one), but /~username/404.html does.. I don't get it but at least it works now! Thanks

The ErrorDocument is a URL, it's not a Unix pathname.

 

/~user/file is a URL that becomes /home/user/public_html/file when the web server fetches it.

 

/home/user/file is a URL that becomes /usr/local/apache/htdocs/home/user/file (a pathname

based in the root of the web server).

 

You can specify any URL, even a URL on another machine...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...