我想将404错误页面重定向到index.php页面,因为我们已经完全重命名了所有URL。。我们使用的是PHP,服务器是Windows。。我们可以在Linux服务器上的.htaccess文件中执行此操作。。但不知道如何在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服务器,则可以在Linux中使用.htaccess文件。
如果使用的是Windows Server IIS,则可以使用web.config文件。
您可以在此处查看有关如何配置web.config文件以在404错误时重定向的更多信息。
也许这就是你要寻找的。
如果您有apache,那么相同的.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>