how to redirect http://domain.com to http://www.domain.com permanently

Discussion in 'Site & Server Administration' started by seoindiaweb, Nov 16, 2006.

Thread Status:
Not open for further replies.
  1. #1
    Hello there,
    I somewhere learned here on DP that you can permanent redirect the http:/domain.com to http:/www.domain.com through .htaccess
    but i dont know the exact rule of that
    Would anyone please give me that rule to write the above mentioned situation

    Thanx
     
    seoindiaweb, Nov 16, 2006 IP
  2. deezorder

    deezorder Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try


    RewriteEngine on

    RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301]
     
    deezorder, Nov 16, 2006 IP
  3. iatbm

    iatbm Prominent Member

    Messages:
    5,151
    Likes Received:
    352
    Best Answers:
    0
    Trophy Points:
    360
    #3
    
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
    RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301]
    
    Code (markup):
    in your .htaccess :D
     
    iatbm, Nov 16, 2006 IP
Thread Status:
Not open for further replies.