Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
webdesign.about.com/od/apache/ht/ht404apache.htm is a short guide. –  N.N. Jul 15 '11 at 12:50

4 Answers 4

up vote 18 down vote accepted

I found the answer myself.

You have to edit the file /etc/apache2/conf.d/localized-error-pages

sudoedit /etc/apache2/conf.d/localized-error-pages

You can enter plaintext or link to a script or html

share|improve this answer

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.

ErrorDocument 404 /pathtofile

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:

ErrorDocument 404 '<h1>404 Not Found</h1>'

You don't have to reload Apache Server ! It's finished. Test it out.

Source - Subin's Blog

share|improve this answer
    
This would require "AllowOverride" config in apache to be on, which is not the default in ubuntu. –  Capt.Nemo Jun 19 '13 at 10:26
    
This worked for me –  SimplySimon Jun 19 '13 at 11:36
<VirtualHost 192.168.0.1:80>
    ServerAdmin [email protected]
    ServerName host.ru
    ServerAlias www.host.ru
    DocumentRoot /home/WebServer/www/host.ru/public_html/
    ErrorLog /home/WebServer/www/host.ru/logs/error.log
    CustomLog /home/WebServer/www/hostu/logs/access.log combined


    Alias /error_html/ "/home/WebServer/www/host/error_html/"
    <Directory "/home/WebServer/www/host.ru/error_html">
        AllowOverride None
        Options IncludesNoExec
        AddOutputFilter Includes html
        AddHandler type-map var
        Order allow,deny
        Allow from all
        LanguagePriority en cs de es fr it nl sv pt-br ro
        ForceLanguagePriority Prefer Fallback
    </Directory>
    ErrorDocument 404 /error_html/HTTP_NOT_FOUND.html
</VirtualHost>
share|improve this answer

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:

ErrorDocument 404 http://www.yoursite.com

Then save the file.

This will make the 404 page redirect to the specified URL.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.