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.

 

 

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>