mod_rewrite vs. 301 redirect

Discussion in 'Site & Server Administration' started by popoman, Mar 4, 2007.

  1. #1
    In order to prevent duplicates in SE's what's better; a mod_rewrite or a 301 redirect if redirecting a subdomain to a domain?

    Thanks!
     
    popoman, Mar 4, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    A rewrite is transparent to the user - if not done carefully, it will lead to duplicate content as the same page will be accessible from different URLs.

    A 301 redirect can't create duplicate content since it tells the user that the page has moved and to request it from its new location.
     
    rodney88, Mar 4, 2007 IP
  3. popoman

    popoman Peon

    Messages:
    95
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ok so if I want to both have all links point at my www. domain and tell Google that my subdomain is moved permanently to my www. domain will this be the code for the .htaccess?

    # mod_rewrite in use
    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain.com [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    
    redirect 301 / http://www.domain.com/
    Code (markup):
    The "/" of the 301 means I place it in the root folder of my subdomain right?

    Thanks!

    P.S. Did I miss any backslashes?
     
    popoman, Mar 5, 2007 IP
  4. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If you're using the R=301 flag for a RewriteRule, it'll be identical to using a Redirect 301 command.
     
    rodney88, Mar 5, 2007 IP
  5. popoman

    popoman Peon

    Messages:
    95
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ok, thanks for making it clear.
     
    popoman, Mar 6, 2007 IP