How to create a custom 404 message on Apache

Опубликовано: 29 Октябрь 2024
на канале: solron75
4,706
25

How to create a custom 404 message on Apache

You can find the written instructions here:
http://soltveit.org/apache-custom-404...

This example is done on a Debian machine. Should be the same on most Linux distros. Not sure if the AllowOverride setting is done the same way on all Linux distros (Or where the sites-available files are).

The standard 404 (Page not found) is enough for telling someone the page they are looking for is not there. However you can use that 404 traffic to share funny pages, or redirect them to your main page. Or you can promote product, adverts and such. What ever you want to use your 404 traffic for. Here is how you do it.

Ssh into your web server, if your not local, and navigate to your root folder of your website.

Example: /var/www/example.com/



Create a .htaccess file if you don't have one from before. And add this to your .htaccess file.

ErrorDocument 404 /404.html

The above line says if a 404 error, go to 404.html. And this example assume the 404.html file is located in the website root folder.
Example of a 404.html file: See the link above as YouTube doesn't allow brackets.

Anyway, happy redirecting!