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
add comment

4 Answers

up vote 16 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
add comment

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
add comment
<VirtualHost 192.168.0.1:80>
    ServerAdmin admin@host.ru
    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
add comment

edit file your virtual hosts

gedit /etc/apache2/sites-available/host.ru

and add your path for folder error_html with error.html

<VirtualHost 192.168.0.1:80>
ServerAdmin admin@рhost.ru
ServerName host.ru
ServerAlias www.criterion.ru
DocumentRoot /home/WebServer/www/host.ru/public_html/
ErrorLog /home/WebServer/www/host.ru/logs/error.log
CustomLog /home/WebServer/www/host.ru/logs/access.log combined

# add here
# добавляем тут
Alias /error_html/ "/home/WebServer/www/host.ru/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
add comment

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.