How to remove index.php in url in wordpress in windows server/iis

When you going to live your wordpress site in windows server then you see by default index.php in you url this very common issue.
You can remove the index.php without affecting your current pages.

1. First Removing /index.php/ from Permalinks

2 Add web.config file root and add the following code in to the web.config file.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="5.00:00:00" />
        </staticContent>
        <httpProtocol>
            <customHeaders>
                <add name="Access-Control-Allow-Origin" value="*" />
            </customHeaders>
        </httpProtocol>
        <!--<httpErrors errorMode="Detailed" />-->
        <rewrite>
            <rules>            
                <rule name="Main Rule" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:0}" />
                </rule>
                <rule name="WordPress: https://website.com" patternSyntax="Wildcard">
                    <match url="*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Note: When you use rewrite rule some time problem in images(images not sowing). But above code solve your index.php and also images sowing problem.

Leave a Reply

Your email address will not be published. Required fields are marked *