【问题标题】:How to redirect 404 error page using php in windows server如何在 Windows 服务器中使用 php 重定向 404 错误页面
【发布时间】:2013-12-02 09:02:01
【问题描述】:

我想将 404 错误页面重定向到 index.php 页面,因为我们已经完全重命名了所有 url。我们使用的是 PHP,服务器是 Windows。我们可以在 Linux 服务器上的 .htaccess 文件中执行此操作。但是没有想法如何在Windows中做到这一点..请帮助。 This is the Question Simillar to my Question

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <httpErrors>
        <error statusCode="500" subStatusCode="100" path="/iisHelp/500-100.asp" responseMode="ExecuteURL" />
    </httpErrors>
</system.webServer>
<system.web>
    <customErrors mode="Off">
        <error statusCode="404" redirect="/index.html" />
    </customErrors>
</system.web>
<system.net>
    <mailSettings>
        <smtp deliveryMethod="Network" from="postmaster@embassyresidency.com">
            <network defaultCredentials="true" host="embassyresidency.com" />
            <specifiedPickupDirectory pickupDirectoryLocation="C:\inetpub\mailroot\Pickup" />
        </smtp>
    </mailSettings>
</system.net>

我在 web.config 中使用过这段代码。但是重定向不起作用..任何其他想法..

【问题讨论】:

标签: php windows url-redirection


【解决方案1】:

如果您使用 Apache httpd 运行 Windows Server,您可以使用 .htaccess 文件以及在 Linux 中。

如果您使用的是 Windows Server IIS,则可以使用 web.config 文件。

您可以查看here,了解如何配置 web.config 文件以重定向 404 错误。

也许这就是您要搜索的内容。

【讨论】:

  • 该目录中已经有 web.cofig 文件。所以我猜服务器是Windows Server IIS。我做了一些更改,但仍然无法正常工作..
  • 您尝试了哪些更改?更改后是否重新启动 IIS?
【解决方案2】:

如果你有 apache,同样的 .htaccess 文件应该可以工作。

【讨论】:

    【解决方案3】:

    使用此代码:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <httpErrors>
                <remove statusCode="404" subStatusCode="-1" />
                <error statusCode="404" prefixLanguageFilePath="" path="error\404.php" />
             </httpErrors>
        </system.webServer>
    </configuration>

    【讨论】:

      猜你喜欢
      • 2016-01-06
      • 1970-01-01
      • 2013-06-09
      • 2011-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-28
      • 1970-01-01
      相关资源
      最近更新 更多