找不到404页面错误

时间:2012-09-24 08:46:39

标签: php .htaccess

我正在使用WAMP服务器,我需要使用htaccess更改“404 not found page”样式。我该怎么办?

“找不到”

在此服务器上找不到请求的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

3 个答案:

答案 0 :(得分:1)

您可以阅读有关Custom Error Responses

的官方文档

简而言之,请使用此指令:

ErrorDocument 404 /Lame_excuses/not_found.html 

确保您在基本配置文件中设置 AllowOverride所有(或 FileInfo )。

答案 1 :(得分:0)

使用以下代码

ErrorDocument 404 /404page.html

404page.html页面中,您可以将内容显示为无法找到404的内容。在您的情况下,“The requested URL /viewprofile.php was not found on this server

答案 2 :(得分: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文件更好。

相关问题