1

我正在使用 WAMP 服务器,我需要使用 htaccess 更改“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
4

3 回答 3

1

您可以阅读有关自定义错误响应的官方文档

简而言之,使用这个指令:

ErrorDocument 404 /Lame_excuses/not_found.html 

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

于 2012-09-24T08:51:45.027 回答
0

使用以下代码

ErrorDocument 404 /404page.html

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

于 2012-09-24T08:52:30.013 回答
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 文件要好。

于 2012-09-24T09:16:02.527 回答