WordPress.org

Ready to get started?Download WordPress

Forums

How to combine WP Permalinks and non-www to www on IIS7 (3 posts)

  1. soc_j
    Member
    Posted 2 years ago #

    Hi, I have an IIS 7 Server and I've configured web.config file to use Permalinks with this code:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <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>
    </rules>
    </rewrite>
    </system.webServer>
    </configuration>

    and I have another code to change non-www to www calls, this is the code:

    <?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="^mydomain.com$" />
    </conditions>
    <action type="Redirect" url="http://www.mydomain.com/{R:0}" redirectType="Permanent" />
    </rule>
    </system.webServer>
    </configuration>

    Separate codes are working properly but combined doesn't work
    There is a way to combine those codes and work properly?

    Thanks in advanced

  2. soc_j
    Member
    Posted 2 years ago #

    Hi, anyone have any idea?

    Thanks in advanced

  3. soc_j
    Member
    Posted 2 years ago #

    Hi, finally I solve this situation with this code in "web.config"...

    -----------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <rewrite>
    <rules>
    <rule name="Canonical Host Name" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
    <add input="{HTTP_HOST}" negate="true" pattern="^mydomain\.com$" />
    <add input="{URL}" negate="true" pattern="scoresubmit\.php$" />
    </conditions>
    <action type="Redirect" url="http://www.mydomain.com/{R:1}" redirectType="Permanent" />
    </rule>
    <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>
    </rules>
    </rewrite>
    </system.webServer>
    </configuration>
    ---------------------------------

    I hope that is helpful for someone with the same problem...

Topic Closed

This topic has been closed to new replies.

About this Topic