简体   繁体   中英

How to redirect 404 error page using php in windows server

I want to Redirect 404 error page to index.php page since we have completely renamed all urls.. We are using PHP and the server is Windows.. We can do this in .htaccess file on Linux server.. But no idea How to do it in Windows.. Please help. 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>

I've used this code in web.config. But redirection is not working.. Any other ideas..

If you're running a Windows Server with Apache httpd you can use .htaccess files as well as in Linux.

If you're using the Windows Server IIS you can use web.config files.

You can take a look here for more information how to configure web.config files to redirect on 404 errors.

Maybe this is what you searching for.

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

Use this code:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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