301 - which one is right ?

Discussion in 'Programming' started by tommseo, Mar 12, 2009.

  1. #1
    I want 301 redirect, please tell me which one is right code


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

    or

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


    in the first code there is [NC].
     
    tommseo, Mar 12, 2009 IP
  2. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #2
    The first one is better.
     
    buldozerceto, Mar 12, 2009 IP
  3. Lalucochin

    Lalucochin Active Member

    Messages:
    518
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #3
    You can use both the codes for 301 permanent redirect. The best of the two codes is the first one as it looks more specific. The [NC] makes it look more specific.
     
    Lalucochin, Mar 12, 2009 IP