Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sebastian Dammark 547 posts 1287 karma points
    Jun 30, 2015 @ 16:21
    Sebastian Dammark
    0

    UrlRewrite - remove www from URL

    I think I'm doing it the right way, but nothing happens:

    <add name="Remove WWW" 
         virtualUrl="(.*)://www(.*)" 
         rewriteUrlParameter="ExcludeFromClientQueryString" 
         destinationUrl="$1://$2" 
         ignoreCase="true" />
    

    So, I'm most likely doing it the wrong way.

    What's wrong with the rule above ?

  • Jason Prothero 416 posts 1226 karma points c-trib
    Jun 30, 2015 @ 16:51
    Jason Prothero
    0

    I blogged about this a couple years back:

    http://www.proworks.com/blog/2011/03/31/permanent-301-redirect-domaincom-to-wwwdomaincom-in-umbraco/

    Basically, this works for me to add the www so I think you could repurpose it to remove the www.

    <add name="SEOfix"  virtualUrl="^http\://domain.com/(.*)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="http://www.domain.com/$1" redirect="Domain" redirectMode="Permanent" ignoreCase="true" /> 
    

    See more at: http://www.proworks.com/blog/2011/03/31/permanent-301-redirect-domaincom-to-wwwdomaincom-in-umbraco/#sthash.0VeNIxMc.dpuf

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Jul 05, 2015 @ 18:53
    Sebastiaan Janssen
    0

    I use the following rule for this:

        <rule name="Remove www" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_HOST}" pattern="^www\.(.+)$" />
          </conditions>
          <action type="Redirect" url="http://{C:1}/{R:1}" redirectType="Permanent" />
        </rule>
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies