« Previous Next »

Thread: Force site URL

Last post 11-02-2009 6:53 PM by nazaf. 10 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (11 items)

Sort Posts:

  • 10-25-2009, 12:15 AM

    • nazaf
    • Not Ranked
    • Joined on 08-10-2007, 2:09 AM
    • Posts 6

    Force site URL

    Hi,
    I have an ASP.NET 3.5 web site hosted on IIS 7. I need to force the "www" in the URL of my site, so that when users access my site using "http://mysite.com", they get re-directed to "http://www.mysite.com" automatically (address is shown their browser address bar). Does this have to do with IIS and URL ReWriting?? If not then how to achieve that?

     Thanks!

     

  • 10-25-2009, 3:01 AM In reply to

    Re: Force site URL

  • 10-28-2009, 5:30 AM In reply to

    Re: Force site URL

    Hi,

    More detailed about URL rewriting, you can use the following rule

    <rewrite>
          <rules>
            <rule name="Redirect to WWW" stopProcessing="true">
              <match url=".*" />
              <conditions>
                <add input="{HTTP_HOST}" pattern="^mysite.com$" />
              </conditions>
              <action type="Redirect" url="http://www.mysite.com/{R:0}" redirectType="Permanent" />
            </rule>
          </rules>
        </rewrite>

    For more information about URL rewriting, please refer to:
    Using URL Rewrite Module
    http://learn.iis.net/page.aspx/460/using-url-rewrite-module/

    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-28-2009, 8:33 PM In reply to

    • nazaf
    • Not Ranked
    • Joined on 08-10-2007, 2:09 AM
    • Posts 6

    Re: Force site URL

    Can I use this code in web.config file in my web site?

  • 10-28-2009, 8:52 PM In reply to

    Re: Force site URL

    When you have URL rewrite and configure the rules, it will capture in your web.config file. or you can just cut and paste it in your config file, but make sure you got the component installed.

    Cheers,
    Bernard Cheah
  • 11-01-2009, 10:48 AM In reply to

    • rmmason
    • Not Ranked
    • Joined on 08-04-2007, 4:21 PM
    • Sheffield (UK)
    • Posts 9

    Re: Force site URL

     Wow! I didn't realise you could use the rewrite module to perform redirects like this. I did have a seperate site with redirects for each site alias but will be using this from now on.

    Ross Mason

    Inflecto Systems
    www.inflecto.co.uk
  • 11-01-2009, 9:20 PM In reply to

    Re: Force site URL

    That's one of the cool feature of URL REwrite, best of all you can do it with custom rules for max flexibility.

    Cheers,
    Bernard Cheah
  • 11-01-2009, 9:47 PM In reply to

    • nazaf
    • Not Ranked
    • Joined on 08-10-2007, 2:09 AM
    • Posts 6

    Re: Force site URL

    So which is better in terms of performance, the UrlRewriter.NET component, or IIS 7 URL rewrite module??

  • 11-01-2009, 10:22 PM In reply to

    Re: Force site URL

    Well, no idea have not benchmark at all, and have yet try urlrewrite.net as iis url rewrite so far fit into my requirement well :)

    Cheers,
    Bernard Cheah
  • 11-02-2009, 1:19 PM In reply to

    • DanielVL
    • Top 75 Contributor
    • Joined on 10-07-2006, 6:00 PM
    • Redmond, WA, USA
    • Posts 109

    Re: Force site URL

    URL Rewrite is cache friendly, meaning that for frequently hit URLs the redirection will happen really fast, a hashtable look up and then a native Redirect call. Expect great performance.

    Daniel Vasquez Lopez
    URL Rewrite Engine Developer
  • 11-02-2009, 6:53 PM In reply to

    • nazaf
    • Not Ranked
    • Joined on 08-10-2007, 2:09 AM
    • Posts 6

    Re: Force site URL

    So IIS 7 URL rewrite module is better than the UrlRewrite.net component, isn't it? Or is it  not that big difference?

Page 1 of 1 (11 items)
Microsoft Communities