Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm running a local test-server (on Ubuntu 10.04), but for some reason I don't seem to be seeing my custom 403/404 error messages. Here's some command output:

[ /var/www ] # ls -al:

drwxr-xr-x  5 www-data www-data 4096 2010-07-31 18:40 .
drwxr-xr-x 16 root     root     4096 2010-05-14 19:56 ..
-rwxr-xr-x  1 www-data www-data  493 2010-07-31 18:32 403.html
-rwxr-xr-x  1 www-data www-data  493 2010-07-31 18:10 404.html
-rwxr-xr-x  1 www-data www-data   56 2010-07-31 18:25 .htaccess

[ /var/www ] # cat .htaccess:

ErrorDocument 404 /404.html
ErrorDocument 403 /403.html

I'm completely stumped - can't find any info through Google either.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I've read that the base Apache config file for the default VirtualHost in Ubuntu is to set the AllowOverride directive in the DocumentRoot directory to None instead of All. This means that .htaccess files will not be parsed and therefore your ErrorDocument directives will not be parsed.

Changing it to AllowOverride All should activate the ability to use .htaccess files and therefore your custom ErrorDocuments should work.

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    # This directive allows us to have apache2's default start page
    # in /apache2-default/, but still have / go to the right place
    # Commented out for Ubuntu
    #RedirectMatch ^/$ /apache2-default/
</Directory>

See Enabling Use of Apache htaccess files on Ubuntu's help wiki or this post on UbuntuForums.org for a more detailed explanation. Hope that helps. Alternatively, you could set the ErrorDocument directive in the VirtualHost record in the Apache config file instead of an .htaccess file.

share|improve this answer
    
After setting AllowOverride All and running sudo service apache2 restart, it works! –  Josh Jul 31 '10 at 20:55

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.