1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do I redirect non www pages to www on a windows server & index.php to abc.com for https ?

Discussion in 'White Hat SEO' started by pulkitseo, Jun 27, 2016.

  1. pulkitseo

    pulkitseo Senior Member

    Joined:
    Apr 25, 2013
    Messages:
    1,053
    Likes Received:
    134
    Home Page:
    Hello I have below listed requirements for re-directions :
    • Redirection to be done is on secure server.
    • Window server hence web config file is required (need coding)
    • Non www to www url
    • abce.com/index.php to abc.com
    Please help me with code.
    Below is the code which i find is right.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <rewrite>
    <rules>
    <rules>
    <rule name="DefaultRule" stopProcessing="true">
    <match url="^index.php" />
    <action type="Redirect" url="/" />
    </rule>
    <rule name="CanonicalHostNameRule1" stopProcessing="true">
    <match url="index\.asp(?:l)?" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="domain\.com$" />
    </conditions>
    <action type="Redirect" url="http://www.domain.com/" />
    </rule>
    <rule name="CanonicalHostNameRule2" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^domain\.com$" />
    </conditions>
    <action type="Redirect" url="http://www.domain.com/{R:1}" />
    </rule>
    </rules>
    </rules>
    </rewrite>
    </system.webServer>
    </configuration>

    Thanks and regards