Access .htaccess Error 404

0

Using the Xampp (Apache).

If we want to access a page on our web server , which does not exist, then we should return an error of Page not found , and we should redirect it to a page error404 , that we have designed, in my case: error404.php

.htaccess code:

ErrorDocument 404 http://localhost:8081/daw/error404.php

Why does not it work with just putting the next sentence?

ErrorDocument 404 error404.php

I show the directory where I have the files, they are all at the SAME LEVEL.

    
asked by omaza1990 09.01.2018 в 21:38
source

1 answer

1

Good morning,

To put the relative path in the htaccess, you will have to put the path from the parent folder of the localhost, that is, from the htdocs.

Try this in the .htaccess

ErrorDocument 404 /daw/error404.php

My file path is xampp / htdocs / cbs / mycbs / 404.php

And in my .htaccess the route is as follows:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Options -Indexes
ErrorDocument 404 /cbs/mycbs/404.php
    
answered by 10.01.2018 в 16:33