Raspberry Pi 404 error redirection

It’s pretty frustrating when you finished all the setups and trying to get onto your website, the Pi gives you a 404 error, and it’s in a very poor manner..not in a decent page.

Then I come across to custom the 404 redirect page in the Apache configuration file, which located in “/etc/apache2/conf.d”, the path is pretty different from what you are having in Windows.

The file name is localized-error-pages.

You will have to change below to your own custom page:

As you can see, I added one line specifically for the Error page, which is located in /var/www/error/missing.php, wait, how come the path is different from the system path?

It turns out when Apache reads file, it simply reads starting from the server root folder, which obviously is /var/www/.

And one more thing, don’t forget to first slash / before the directory name, otherwise you will get a literal string in your webpage, like below.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *