IIS7 / WordPress URL Rewrite with Redirect from domain.com to www.domain.com
-
I am trying to correct a 302 redirect on my domain.com to http://www.domain.com.
To start, I am completely UNSURE where this redirect is coming from as it is not setup in any files that I can find.
This is my current web.config file:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="wordpress" 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>
This is the potential solution I have found through a lot of googling and reading:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Redirect to WWW" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="^domain\.com$" /> </conditions> <action type="Redirect" url="http://www.domain.com/{R:1}" redirectType="Permanent" /> </rule> <rule name="wordpress" 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>
Before I go ahead and start implementing this, I was hoping for a comment from the community on whether or not this is the right direction.
Thanks!
- The topic ‘IIS7 / WordPress URL Rewrite with Redirect from domain.com to www.domain.com’ is closed to new replies.