IIS Host Headers and non WWW to WWW

前端 未结 1 1166
闹比i
闹比i 2021-01-27 19:52

I know there\'s a bunch of examples on how to redirect your non www to your www site, but I\'m not using any rewrite utils/ISAPI.

On my Windows 2008R2 box, I have severa

相关标签:
1条回答
  • 2021-01-27 20:35

    I guess there are two ways. One is to create a rewrite rule through the IIS manager.

    The other is to setup the system.webserver section of the web.config as follows:

      <system.webServer>
    
        <rewrite>
          <rules>
            <clear/>
            <rule name="Redirect Non WWW to WWW" enabled="true" stopProcessing="true">
              <match url="(.*)" />
              <conditions>
                <add input="{HTTP_HOST}" negate="true" pattern="^www\.([.a-zA-Z0-9]+)$" />
              </conditions>
              <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
            </rule>
    
            <!--<rule name="Default Document" stopProcessing="false">
              <match url="(.*)default.aspx"/>
              <action type="Redirect" url="{R:1}" redirectType="Permanent"/>
            </rule>-->
    
          </rules>
        </rewrite>
    
        <validation validateIntegratedModeConfiguration="false"/>
        <modules runAllManagedModulesForAllRequests="true"/>
    
        <httpErrors errorMode="Custom"/>
    
      </system.webServer>
    
    0 讨论(0)
提交回复
热议问题