自定义错误文档不显示@localhosttesting服务器

我正在运行一个本地testing服务器(在Ubuntu 10.04上),但由于某种原因,我似乎没有看到我的自定义403错误消息。 这里有一些命令输出:

[ /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 

我完全难住 – 无法通过Googlefind任何信息。

我读过Ubuntu的默认VirtualHost的基本Apacheconfiguration文件是将DocumentRoot目录中的AllowOverride指令设置为None而不是All。 这意味着.htaccess文件将不会被parsing,因此您的ErrorDocument指令将不会被parsing。

将其更改为AllowOverride All应激活使用.htaccess文件的function,因此您的自定义ErrorDocuments应该可以工作。

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

请参阅在Ubuntu的帮助wiki上启用Apache htaccess文件或在UbuntuForums.org上的这篇文章中获取更详细的解释。 希望有所帮助。 或者,您可以在Apacheconfiguration文件中的VirtualHostlogging中设置ErrorDocument指令,而不是.htaccess文件。