4
votes

I am using .htaccess in my project, i just use the following code

ErrorDocument 404 /404.php

in the .htaccess inside the root folder, but it does not redirect to 404.php while trying to open the misspelt webpage.

I want to know whether there is syntax error in the .htaccess file.

I used .html file instead for .php file. but it throws the same error.


Not Found

The requested URL /ht/re was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

1
Syntax looks right. What does the error log say? Sounds like 404.php is not in the right place for some reason? - Gohn67
Nope, i already have 404.php in the directory. But [ ErrorDocument 404 "<H1>Page not found here</H1>" ] This is working [ ErrorDocument 404 /404.html ] - This is not working. I mean when i give to display as a text inside .htaccess folder it is working but when i link to a file it is not working - Sulthan Allaudeen
What does your error log say? What you have should work. Have you tried adding this directly to your apache config? Alternative check if your AllowOverride directive is permissive enough. httpd.apache.org/docs/2.2/mod/core.html#allowoverride - Gohn67
No i didn't tried directly to apache config. because i have many directory which should have different types of custom errors so i should use individual .htaccess for seperate directories. - Sulthan Allaudeen
If you are using a vhost, you can add that to your vhost config for that site. - Gohn67

1 Answers

2
votes

first you have to locate your errorpage

i.e. on local server my 404.php in root/error then

ErrorDocument 404 /error/404.php

here first slash is root of server

your server could not find 404.php thats problem so locate your 404.php