2010-12-07 153 views
0

我试过用Apache上的.htaccess文件来做这件事,但却无法让它重定向到自定义404页面。它会继续使用默认的Apache 404页面。自定义404错误htaccess不能在apache 2上工作

这是我做了什么:

我已经把.htaccess文件和一个自定义的404文件(网页未found.php)到我家所在的目录的index.php是。

这是在.htaccess文件行: 的ErrorDocument 404 /page-not-found.php

我也尝试了完整的文档路径: 的ErrorDocument 404 /无功/网络/ htdocs中/页,不-found.php

我已经确定在'/ etc/apache2/sites-enabled/default'和'/ etc/apache2/sites-available/default''AllowOverride'被设置为'All'as如下:

<Directory /var/www/htdocs/> 
      Options Indexes FollowSymLinks MultiViews 
      AllowOverride All 
      Order allow,deny 
      allow from all 
    </Directory> 

我确保AccessFileName在http d.conf是.htaccess

我在每次更改后重新启动apache。

这一切都没有工作,它仍然使用默认的Apache 404文件。厌倦的事情是,这在同一台服务器上的vritual网站上工作,但不会在默认网站上工作。单独但同样的问题:我也无法让它在我自己的电脑上的本地主机上工作。

(Arggghhhhhhh !!!!!!!!!!)

我缺少什么?

+0

过去的.htaccess的代码也后再重新启动Apache。你有没有在你的.htaccess文件中加入这个东西?ErrorDocument 404 /notfound.html – 2010-12-07 11:55:34

+0

.htaccess的代码在 – Mladen 2010-12-07 12:16:53

回答

0

你是否启用了mod?

sudo a2enmod rewrite 

您需要安装