Suddomain Rewrite Rule

Discussion in 'DNS/Domain names' started by cmortazavi, Sep 9, 2011.

  1. Hello I have a wordpress subdirectory site which i would like to rewrite to a subdomain. I have used IIS to write the following code in my web.config in my root website not my subdirectory.

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true" />
     
      <rewrite>
          <rules>
            <clear />
     
    <!-- Spatialwave Website Support1 -->
     
    <rule name="spatialwave-Web-support1" enabled="true" stopProcessing="true">
              <match url="(.*)" />
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="^www\.support1\.spatialwave\.com$" />
              </conditions>
              <action type="Redirect" url="http://support1.spatialwave.com/{R:0}" />
            </rule>
     
            <rule name="spatialwave-Web-support1-rewrite" enabled="true" stopProcessing="true">
              <match url="(.*)" />
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="^(www\.)?support1\.spatialwave\.com$" />
                <add input="{PATH_INFO}" pattern="^/support1/($|/)" negate="true" />
              </conditions>
              <action type="Rewrite" url="/support1/{R:0}" />
            </rule>
                    <rule name="Test" enabled="false" patternSyntax="Wildcard">
                        <match url="*" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{HTTP_HOST}" pattern="support1.spatialwave.com" />
                        </conditions>
                        <action type="Rewrite" url="support1/{R:0}?" />
                    </rule>
     
          </rules>
        </rewrite>
        <urlCompression doStaticCompression="true" doDynamicCompression="true" />
      </system.webServer>
    </configuration>

    The rule works fine but, when you go to the site support1.spatialwave.com is ony the homepage but all the other pages have the address of spatialwave.com/support1. IS there any way to rewrite the URL of all my pages within the subdirectory? Any help would be much appreciated. Thanks.
     
  2. Ray

    Ray

    I think your pattern which IIS monitors is incorrect or not complete. It looks like you are only looking for http calls with support1.spatialwave.com. If someone calls on spatialwave.com it does not filter or rewrite it.
     

Share This Page