Details 404 page replacement by configuring Apache

  • 2020-06-19 12:26:24
  • OfStack

Details 404 page replacement by configuring Apache

1. General - Modify the apache configuration.htaccess

1 Generally, the reason for website 404 is that the resource cannot be found. The server (take Apache for example) reported an error. Apache customized 404 output.

Then you have the following code and procedure:

For Apache server: make 1 404 page, the page can be designed by yourself, named notfound.php, upload to the root directory of the website. Open the.htaccess file, add the code: ErrorDocument 404 / notfound.php (note the space between 404 and /), and upload the.htaccess file to the site root. If.htaccess has ErrorDocument 404 / index.php, 1 must delete it. This practice of redirecting 404 errors to the home page of a web site is highly risky and can cause the home page to disappear from search engines. END

Example:


<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
 
ErrorDocument 404 /notfound.php
 
</IfModule>

The above is the detailed explanation of the replacement of 404 page through configuration Apache. If you have any questions, please leave a message or discuss in our community. Thank you for reading.


Related articles: