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

pulkitseo

Supreme Member
Joined
Apr 25, 2013
Messages
1,342
Reaction score
233
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
 
Back
Top