cancel
Showing results for 
Search instead for 
Did you mean: 

error 404 in .htaccess not working

SoulBriski
Grafter
Posts: 179
Registered: ‎15-06-2007

error 404 in .htaccess not working

All of a sudden the info in my .htaccess file regarding 404 errors have stopped working.
The two relevant lines in my .htaccess file are...
ErrorDocument 403 /forbidden.php
ErrorDocument 404 /errors.php
If I mistype a page address, I get a standard 404 page error not my own and equally if I enter wrong credentials i get a standard 'forbidden' page and not my own custom one.
Can anyone tell me whats gone wrong suddenly? I cannot think of anything i have changed which would effect this.
Many thanks
3 REPLIES 3
SoulBriski
Grafter
Posts: 179
Registered: ‎15-06-2007

Re: error 404 in .htaccess not working

I've solved this myself now.
I've changed the lines in my .htaccess file as follows:-
ErrorDocument 403 <My Full URL>/forbidden.php
ErrorDocument 404 <My Full URL>/errors.php
It was failing because there are subdirectories that the user might be in at the time that he navigates to a broken link and so the errors.php may not be in the same directory (relative) as he is in at the time.
It was a stupid oversight on my part
Prod_Man
Grafter
Posts: 287
Registered: ‎04-08-2007

Re: error 404 in .htaccess not working

Thanks for posting the Solution Smiley
Always useful for Future Reference.
I was going to reply to this, but I didn't have the time.
I thought it was along the lines of a bad path somewhere,
when I read it but I assumed .htaccess's worked from their root path,
and assumed all your pages were in the root path.
Jim,
Peter_Vaughan
Grafter
Posts: 14,469
Registered: ‎30-07-2007

Re: error 404 in .htaccess not working

Your root (home) folder is not the root of the filesystem so doing /filename.php does not refer to a file in your root folder but in the root of the filesystem.
Your root folder is actually /files/homeX/username where X is a number. So you need to use the full path to refer to the error document in the .htaccess file. So it would be /files/homeX/username/error.html.
To find you full path just use pwd from the shell prompt.