【问题标题】:404 page not found error404 页面未找到错误
【发布时间】:2012-09-15 17:00:40
【问题描述】:

我正在使用 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

【问题讨论】:

标签: php .htaccess


【解决方案1】:

在您的 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文件要好。

【讨论】:

    【解决方案2】:

    你可以阅读关于Custom Error Responses的官方文档

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

    ErrorDocument 404 /Lame_excuses/not_found.html 
    

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

    【讨论】:

    • @user1693607 你仔细阅读文档了吗?您需要有适当的 AllowOverride 配置。请参阅我更新的答案。
    【解决方案3】:

    使用以下代码

    ErrorDocument 404 /404page.html
    

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

    【讨论】:

      猜你喜欢
      • 2015-06-22
      • 2015-03-30
      • 1970-01-01
      • 1970-01-01
      • 2016-01-18
      • 1970-01-01
      • 2017-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多