www.sitename.com to sitename.com

Discussion in 'Apache' started by vic_msn, May 25, 2006.

  1. #1
    vic_msn, May 25, 2006 IP
  2. infin8

    infin8 Peon

    Messages:
    42
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It shouldn't matter which one you go with if you're redirecting them.

    Here is the code for mod_rewrite to do 301. There are a million ways to do it, but I prefer mod_rewrite.

    To remove the www
    
    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} !^template-site\.com$ [NC]
    RewriteRule .* http://template-site.com/ [L,R=301]
    
    Code (markup):
    To add the www
    
    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} !^www\.template-site\.com$ [NC]
    RewriteRule .* http://www.template-site.com/ [L,R=301]
    
    Code (markup):
     
    infin8, May 25, 2006 IP
  3. vic_msn

    vic_msn Well-Known Member

    Messages:
    2,233
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    155
    #3
    thanks i will implement this :)
     
    vic_msn, May 25, 2006 IP