« Previous Next »

Thread: Redirecting www to non-www?

Last post 10-23-2009 2:17 PM by CarlosAg. 5 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (6 items)

Sort Posts:

  • 01-01-2009, 5:51 AM

    • reteep
    • Top 500 Contributor
    • Joined on 06-30-2005, 9:27 AM
    • Germany
    • Posts 16

    Redirecting www to non-www?

    Happy new year everyone!

    I've setup two sites in IIS7:
    domain.com
    www.domain.com

    Now I'd like to have www.domain.com being 301 redirect to domain.com. So I enabled HTTP Redirection on the www.domain.com account to redirect all requests to domain.com. However, as soon as it's enabled, Firefox tells me for both urls:

    Redirect Loop: Redirection limit for this URL exceeded.  Unable to load the requested page.  This may be caused by cookies that are blocked.

    How do I set this up correctly?

    Thanks,
    Andreas

  • 01-01-2009, 10:21 AM In reply to

    Re: Redirecting www to non-www?

    Normally you would simply use two DNS records to point to the same IP address and site, not do any redirects.  If DNS was configured with an alias for the blank host pointing to the www host you might get a loop.

    Jeff

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
  • 01-02-2009, 1:17 PM In reply to

    • reteep
    • Top 500 Contributor
    • Joined on 06-30-2005, 9:27 AM
    • Germany
    • Posts 16

    Re: Redirecting www to non-www?

    Hello Jeff,

    thanks for your answer. I do use two DNS records which point to the same IP. However, I'd like to redirect the www. domain to the non www. domain to actually force people to use http://domain.com.

    It worked with IIS6 already, I actually did the same thing there. With IIS7 I'm getting a loop error as soon as I enable the redirect on "www.domain.com".  Any other idea?

    Thanks,
    Andreas

  • 01-07-2009, 8:42 PM In reply to

    Re: Redirecting www to non-www?

    Hi,

    Do your two websites have the same physical path ?

    There are some differences between the IIS6.0 and IIS7.0 Http Redirect feature. With IIS6.0, the setting via this feature is stored  as a key in the Metabase. With IIS7.0, This configuration is stored in the web.config file in the section  <configuration> <httpRedirect/> </configuration>. 

    If two websites are under the same path, they will use the same web.config file. Then you changes on one site’s Http Redirect feature will be replicated to the other website. This can be the reason of the loop. The solution should be using a different physical path for the redirection site.

     

    Leo Tang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • 10-23-2009, 11:39 AM In reply to

    • neildt
    • Top 500 Contributor
    • Joined on 08-07-2006, 5:35 PM
    • Posts 16

    Re: Redirecting www to non-www?

    I had the exact same problem.  I created a new site pointing to a new directory and applied the HTTP response on this new site so now all non www traffic goes to www. 

    For example

    mysite.com/testpages/ is automatically redirected to www.mysite.com/testpages/

    Everything is working fine.

  • 10-23-2009, 2:17 PM In reply to

    Re: Redirecting www to non-www?

    Probably the easiest way to achieve this is using URL Rewrite, it will allow you to do that and many more things in an easy configuration, such as should I pass query string, use relative paths, change SSL to non-ssl, change parameters, etc:

    http://blogs.msdn.com/carlosag/archive/2008/09/02/IIS7UrlRewriteSEO.aspx

Page 1 of 1 (6 items)
Microsoft Communities