繁体   English   中英

如何在Windows Server中使用PHP重定向404错误页面

[英]How to redirect 404 error page using php in windows server

我想将404错误页面重定向到index.php页面,因为我们已经完全重命名了所有URL。。我们正在使用PHP,服务器是Windows。在Windows中执行。请提供帮助。 这是我的问题类似的问题

<?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中使用了此代码。 但是重定向不起作用..其他任何想法..

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

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

您可以在此处查看有关如何配置web.config文件以针对404错误进行重定向的更多信息。

也许这就是您要寻找的。

如果您使用的是同一个.htaccess文件,则应该可以使用。

使用此代码:

 <?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> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM