Mod re_write diff between this and this?

Discussion in 'Apache' started by theblade24, May 17, 2006.

  1. #1
    What is the exact difference between these two in their function? results?

    Is one better than another?

    RewriteCond %{HTTP_HOST} !^www\.sitename\.com [NC]
    RewriteRule ^(.*)$ http://www.sitename.com/$1 [R=301,L]

    RewriteCond %{HTTP_HOST} ^sitename\.com [NC]
    RewriteRule ^(.*) http://www.sitename.com/$1 [R=301,L]
     
    theblade24, May 17, 2006 IP
  2. Slapyo

    Slapyo Well-Known Member

    Messages:
    266
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    I think the first one says that if the url IS NOT www.sitename.com then change it to www.sitename.com.

    The second one says if the url IS sitename.com then change it to www.sitename.com.

    The problem with the first one would be if you had subdomains. Since subdomain.sitename.com doesn't match www.sitename.com it would be changed. So I think the first one would cause a problem with subdomains.
     
    Slapyo, May 20, 2006 IP