Copied to clipboard

Flag this post as spam?

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


  • Ryan 4 posts 84 karma points
    Aug 11, 2016 @ 08:34
    Ryan
    0

    Non www redirect to www

    I am having trouble with redirecting my website from domain.com to www.domain.com. I have used the following line of code in the urlrewriting.config file and it does not seem to be working.

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

    Any help would be great thanks.

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Aug 11, 2016 @ 08:49
    Dennis Aaen
    0

    Hi Ryan and welcome to our :-)

    What if you do something like this.

    <add name="nonWWW"
                    redirectMode="Permanent"
                    redirect="Domain"
                    ignoreCase="true"
                    rewriteUrlParameter="IncludeQueryStringForRewrite"
                    virtualUrl="http://domainname.com/(.*)" 
                    destinationUrl="http://www.domainname.com/$1" 
                     />
    

    Hope this helps,

    /Dennis

  • Ryan 4 posts 84 karma points
    Aug 11, 2016 @ 08:56
    Ryan
    0

    Hi Dennis,

    I tried that and I am still getting a 404 error page when I enter the http://domain.com address.

    Thanks for the help

  • Lucio 23 posts 140 karma points
    Aug 11, 2016 @ 09:13
    Lucio
    0

    Have you recycled the application pool after adding that rule?

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 11, 2016 @ 15:48
    Fuji Kusaka
    0

    Ryan,

    Have you tried setting a Canonical Host Name in IIS ?

  • Nicholas Westby 2005 posts 6843 karma points c-trib
    Aug 11, 2016 @ 16:30
    Nicholas Westby
    0

    Add this to your web.config (replacing "domain.com" with whatever your actual domain is):

      <system.webServer>
        <rewrite>
          <rules>
            <rule name="Redirect non-www to www" enabled="true" 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>
      </system.webServer>
    

    You may have to install Application Request Routing (ARR) 3.0 in IIS for that to work.

  • 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