I want to customise the 404 page of my Apache Webserver on Ubuntu to something other than the general:
Not Found
The requested URL /***** was not found on this server.
______________________________________________________
Apache/*.*.** (Ubuntu) Server at **** Port 80
How can this be accomplished?
I found the answer myself.
You have to edit the file /etc/apache2/conf.d/localized-error-pages
You can enter plaintext or link to a script or html
Here is a solution. Hope it helps.
DEMO
Go to your site's folder.
Create a file named .htaccess (just .htaccess no name only file extension).
Open the file and add the line.
Replace /pathtofile with your 404 page file name which should be situated in the same folder as the file .htaccess . The custom 404 file can be in PHP or HTML. You can also add HTML to it like this:
You don't have to reload Apache Server ! It's finished. Test it out.
Source - Subin's Blog
One kind of 404 customization (not yet covered here) is redirecting the 404 page in VPS Ubuntu to a separate page, such as the site's home page.
To do this, make a file called
.htaccess
in the web root and put this line in it:Then save the file.
This will make the 404 page redirect to the specified URL.
AFAIK you can not customize default error messages of Apache 2.4 in any easy way because those messages are inside the
apache2
executable.However, you can override them using "ErrorDocument" directives which can be used also in
apache2.conf
.An even better way could be using
Include
inapache2.conf
and collect overridden messages in one separate file.Please also see the Apache 2.4 documentation.