cancel
Showing results for 
Search instead for 
Did you mean: 

.htaccess and ErrorDocument

adagio
Grafter
Posts: 196
Registered: ‎03-04-2008

.htaccess and ErrorDocument

I have created a file .htaccess with the following single line
ErrorDocument 404 /notfound.html
Uploaded to root of my CCGI space with permissions octal 644. The file notfound.html exists and displays correctly in browser if directly referenced. However, any attempt to browse a non-existent page produces a bog standard 404 error  Cry Any suggestions gratefully received.
10 REPLIES 10
Peter_Vaughan
Grafter
Posts: 14,469
Registered: ‎30-07-2007

Re: .htaccess and ErrorDocument

You need to use the FULL path to the file which is not from your root folder.
Do a pwd at the ccgi command prompt to get the full path.
adagio
Grafter
Posts: 196
Registered: ‎03-04-2008

Re: .htaccess and ErrorDocument

Peter
Thanks for replying so quickly. My .htaccess file now has a single line of the form:-
ErrorDocument 404 /files/home3/myusername/notfound.html
Does this look right? Sadly the result is the same. I am afraid that my scripting experience has so far been entirely Windows/ASP and this LAMP business is new to me.
adagio
Grafter
Posts: 196
Registered: ‎03-04-2008

Re: .htaccess and ErrorDocument

Peter
I am puzzled about the path.
At:-
http://www.javascriptkit.com/howto/htaccess2.shtml
is stated:-
"The initial slash in the directory location represents the root directory of your site, that being where your default page for your first-level domain is located."
Is this not true?
adagio
Grafter
Posts: 196
Registered: ‎03-04-2008

Re: .htaccess and ErrorDocument

Also from:-
http://www.plus.net/support/webspace/tips_and_info/webspace_faq.shtml
14. How do I add a 404 type error page to my website?
If a visitor to your site clicks a dead link or mistypes a page address, you can present them with your own error page that can provide helpful links back to your site. To create an error page you need to first create the page and upload it to your site. Next, you create or edit a file called .htaccess that should be placed in your root directory. It should contain the following line -
ErrorDocument 404 /notfound.html
notfound.html should be the name and relative path to the error page you created. You don't need any further information, although you could add other errors such as:
ErrorDocument 400 /badrequest.html
ErrorDocument 401 /authorization.html
ErrorDocument 403 /forbidden.html
ErrorDocument 404 /notfound.html
ErrorDocument 500 /internalserver.html
Ben_Brown
Grafter
Posts: 2,839
Registered: ‎13-06-2007

Re: .htaccess and ErrorDocument

I have this in my .htaccess in the root of my space (i.e. ~).
ErrorDocument 404 /404.html

It seems to work fine.
adagio
Grafter
Posts: 196
Registered: ‎03-04-2008

Re: .htaccess and ErrorDocument

I have this in my .htaccess in the root of my space (i.e. ~).
ErrorDocument 404 /notfound.html

and it does not work Embarrassed
Colin
Grafter
Posts: 1,264
Registered: ‎04-04-2007

Re: .htaccess and ErrorDocument

I've just tested this by going to /nothereadsf on your WWW & CCGI webspace and it appears to have given me a custom 404 not found message and not the standard one.
Have you fixed it?
adagio
Grafter
Posts: 196
Registered: ‎03-04-2008

Re: .htaccess and ErrorDocument

Colin
I am not sure how you identified my web spaces but I am sure you have your methods. They are:-
http://ccgi.ringmarch.plus.com/
http://www.ringmarch.plus.com/
I cannot induce either to give me a custom 404 message with either IE7 or Firefox
pierre_pierre
Grafter
Posts: 19,757
Thanks: 3
Registered: ‎30-07-2007

Re: .htaccess and ErrorDocument

If I add some rubbish after the link, HTML or CGI  I get
Sorry the page you asked for does not exist!
Home

The Home button doesnt work thou 
Using Firefox
adagio
Grafter
Posts: 196
Registered: ‎03-04-2008

Re: .htaccess and ErrorDocument

At last! The problem is NOT with the server but rather the browser.
On IE7 Tools-->Internet Options-->Advanced among the selections there is
'Show friendly HTTP error messages' (friendly ;D) By default this is checked. Uncheck and the error page displays as intended.

With FireFox the fault may lie inadvertently with me. I have allowed AVG to install a toolbar. Again among the options is:-

"Let AVG make suggestions. . . . " is checked by default. Uncheck and all is well.
Thanks to all who have helped with suggestions, this has been a most frustrating experience and resulted in much tearing out of hair  Crazy
Given this browser behaviour and the likelihood that most visitors to one's site will be using IE7 with default settings it seems hardly worth while providing them with a friendly error message Sad