2010-12-07 34 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 

您需要安裝