Jump to content

URL rewrite non www to www


lilmer

Recommended Posts

Good day, I have to include www on my website and it works using this rewrite rules:

        <rewrite>
            <rules>
                <rule name="Redirect to www" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="domain.com" />
                    </conditions>
                    <action type="Redirect" url="http://www.domain.com/{R:0}" />
                </rule>
            </rules>
        </rewrite>

but the problem is it gives me an error of Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects. Using google chrome.

 

Link to comment
Share on other sites

Try this.

<rewrite>  
      <rules>  
        <rule name="Redirect to WWW" stopprocessing="true">  
          <match url=".*">  
          <conditions>  
            <add input="{HTTP_HOST}" pattern="^domain.com$">  
          </add></conditions>  
          <action type="Redirect" url="http://www.domain.com/{R:0}" redirecttype="Permanent">  
        </action></match></rule>  
      </rules>  
    </rewrite>  
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.