1

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.

1 Answer 1

1

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.

1
  • After setting AllowOverride All and running sudo service apache2 restart, it works!
    – Zaz
    Jul 31, 2010 at 20:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .