locked
Unable to Redirect non www to www RRS feed

  • Question

  • User945338570 posted

    hi,

    I have two websites http://abc.com and http://jpg.com . jpg.com website is redirected to http://abc.com through web.config. Now the issue is whenever i try to redirect non-www to www version of abc.com the redirection for jpg.com to abc.com not working. 

    Please note that I have FTP access of only one domain abc.com but don't have access of jpg.com

    Here is the existing code in Web.config file. Please modify this to make it work as desired.

    <system.webServer>
            <rewrite>
                <rules>
                   <rule name="CanonicalHostNameRule1">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^abc\.com$" negate="true" />
    						  </conditions>
                        <action type="Redirect" url="http://abc.com/{R:1}" />
                    </rule>
    
              <rule name="Default Document" stopProcessing="true">
    
                <match url="(.*?)/?index\.html$" ignoreCase="true"/>
    			
                <action type="Redirect" url="{R:1}/" />
              </rule>
    		  
    		  <rule name="Remove WWW prefix">
    		  
    		  <match url="(.*)" ignoreCase="true" />
        <conditions>
          <add input="{HTTP_HOST}" pattern="^www\.abc\.com" />
        </conditions>
      <action type="Redirect" url="http://abc.com/{R:1}"
        redirectType="Permanent" />
    			  </rule>   
                    </rules>
            </rewrite>
        </system.webServer>
    



    Monday, June 10, 2013 7:03 AM

All replies

  • User1508394307 posted

    I think this

    <rule name="CanonicalHostNameRule1">
    <match url="(.*)" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^abc\.com$" negate="true" />
    </conditions>
    <action type="Redirect" url="http://abc.com/{R:1}" />
    </rule>

    is the same as

    <rule name="Remove WWW prefix">
    <match url="(.*)" ignoreCase="true" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^www\.abc\.com" />
    </conditions>
    <action type="Redirect" url="http://abc.com/{R:1}" redirectType="Permanent" />
    </rule>

    and you should delete one of them.

    Monday, June 10, 2013 4:29 PM
  • User945338570 posted

    ok

    I deleted that.

    But How to redirect non www to www version.

    Tuesday, June 11, 2013 2:37 AM
  • User945338570 posted

    Please tell me how to redirect non-www to www version of website.

    Tuesday, June 11, 2013 6:01 AM