2012-09-24 217 views
1

我正在使用WAMP服务器,我需要使用htaccess更改“404未找到页面”样式。我该怎么做?404页未找到错误

“未找到

请求的URL /viewprofile.php在此服务器上找到”。这里是我的htaccess文件

RewriteEngine on 
RewriteRule (.*)-(.*).htm$ viewprofile.php?id=$1 
RewriteRule (.*).htm$ viewprofile.php?id=$2 
RewriteRule viewads(.*)\.htm$ viewads.php?id=$1 
RewriteRule (.*)&(.*)\.htm$ homeads.php?id=$2 
RewriteRule (.*).htm$ profile_city.php?id=$1 
RewriteRule (.*).htm$ profile_cast.php?id=$1 



RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php 
+0

已经回答 http://stackoverflow.com/questions/11753912/how-to-style-404-page-in-wamp-server –

回答

1

您可以阅读Custom Error Responses

在官方的文档简而言之,使用此指令:

ErrorDocument 404 /Lame_excuses/not_found.html 

确保你有AllowOverride全部(或文件信息)在基本配置文件中设置。

+0

索里rkosegi,这不是在我的现场工作。 – user1693607

+0

@ user1693607确保您拥有正确的路径和文件。 –

+0

@ user1693607您是否仔细阅读过文档?你需要有适当的AllowOverride配置。看到我更新的答案。 – rkosegi

0

使用下面的代码

ErrorDocument 404 /404page.html 

404page.html页面,您可以把任何你想显示404未找到的内容。在你的情况 “The requested URL /viewprofile.php was not found on this server

0

在你httpd.conf文件,会有一个ErrorDocument部分:

# 
# Customizable error responses come in three flavors: 
# 1) plain text 2) local redirects 3) external redirects 
# 
# Some examples: 
#ErrorDocument 500 "The server made a boo boo." 
#ErrorDocument 404 /missing.html 
#ErrorDocument 404 "/cgi-bin/missing_handler.pl" 
#ErrorDocument 402 http://www.example.com/subscription_info.html 
# 

之后,添加以下代码:

ErrorDocument 404 /error.html 

,将设置将错误页面添加到名为error.html的文件中,并且比使用.htaccess文件更好。