Click here to Skip to main content
15,888,162 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I want to redirect my site from example.com to www.example.com
Posted
Comments
bjdestiny 26-Oct-13 6:14am    
Could you elaborate your question because we could not sort out what exactly is going on?
VICK 26-Oct-13 7:05am    
If you have some domain hosted web on example.com and want to redirect it to www.example.com.

than you have to consult your domain provider for domain change.
thatraja 28-Oct-13 11:00am    
Glad, you have solved the issue

SQL
Option 1: Redirecting example.com/dir/anypage.html to www.example.com/dir/anypage.html (same page)

Use this format if you want a request for any URL at example.com to redirect to the same page at www.example.com. (If you want to redirect to the home page of www.example.com, see option 2 below.)

    RewriteEngine On
    RewriteCond %{HTTP_HOST}  ^example.com [nocase]
    RewriteRule ^(.*)         http://www.example.com/$1 [last,redirect=301]



SQL
Option 2: Redirecting example.com/dir/anypage.html to the www.example.com home page

Use this format if you want a request for any URL at example.com to redirect to the home page of www.example.com. (If you want to redirect to the same page at www.example.com, see option 1 above.)

    RewriteEngine On
    RewriteCond %{HTTP_HOST}  ^example.com [nocase]
    RewriteRule ^(.*)         http://www.example.com/ [last,redirect=301]
 
Share this answer
 
Install url rewrite 2.0 via microsoft web platform installer in your iis and add the following code in the web config file of particular domain:

HTML
<system.webserver>
    <rewrite>
      <rules>
        <rule name="Redirect domain.com to www" patternsyntax="Wildcard" stopprocessing="true">
          <match url="*" />
          <conditions logicalgrouping="MatchAny">
            <add input="{HTTP_HOST}" pattern="abc.com" />
            <add input="{HTTP_HOST}" pattern="ABC.COM" />
            <add input="{HTTP_HOST}" pattern="Abc.com" />
            <add input="{HTTP_HOST}" pattern="ABc.com" />
            <add input="{HTTP_HOST}" pattern="aBc.com" />
          </conditions>
          <action type="Redirect" url="http://www.abc.com/{R:0}" />
        </rule>
      </rules>
    </rewrite>
</system.webserver>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900