redirecting a domain with multiple extensions

Discussion in 'Search Engine Optimization' started by Mark Oates, Dec 6, 2008.

  1. #1
    I own www.allmusiclibrary.com and the related .org and .net extensions. I want to redirect the .org and .net extensions so that they are re-written/redirected to the .com extension.

    I believe that the mod_rewrite isn't the right way to do this. Right now .org/.net will display the same website as the .com, except with the corresponding extension in the address bar... so...

    What's the best SEO way to rewrite the .org and .net extensions to .com?
     
    Mark Oates, Dec 6, 2008 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    Colbyt, Dec 6, 2008 IP
  3. Mark Oates

    Mark Oates Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Alright, seems to work nicely. I dropped these lines in my .htaccess file. Is this coding a little redundant, it seems like there'd be a cleaner way...

    RewriteEngine on
    rewritecond %{http_host} ^allmusiclibrary.net [nc]
    rewriterule ^(.*)$ http://www.allmusiclibrary.com/$1 [r=301,nc] 
    
    rewritecond %{http_host} ^allmusiclibrary.org [nc]
    rewriterule ^(.*)$ http://www.allmusiclibrary.com/$1 [r=301,nc] 
    
    rewritecond %{http_host} ^www.allmusiclibrary.net [nc]
    rewriterule ^(.*)$ http://www.allmusiclibrary.com/$1 [r=301,nc] 
    
    rewritecond %{http_host} ^www.allmusiclibrary.org [nc]
    rewriterule ^(.*)$ http://www.allmusiclibrary.com/$1 [r=301,nc] 
    
    rewritecond %{http_host} ^allmusiclibrary.com [nc]
    rewriterule ^(.*)$ http://www.allmusiclibrary.com/$1 [r=301,nc] 
    Code (markup):
     
    Mark Oates, Dec 6, 2008 IP
  4. oddcomments

    oddcomments Peon

    Messages:
    77
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Don't think so if you want to do it right. You nailed it.
     
    oddcomments, Dec 6, 2008 IP
  5. oddcomments

    oddcomments Peon

    Messages:
    77
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Dooh! Just double check each of the ones you want to redirect. On the condition line you might need a $ at the end of the URL. Like so:
    
    RewriteCond %{HTTP_HOST} ^example.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    
    Code (markup):
     
    oddcomments, Dec 6, 2008 IP
  6. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #6
    I agree about the $ sign. Also you can shorten what you did by using the [OR] as in the following:

    This essentially says that either of the first two sites gets redirected to the last site in the list.
     
    Colbyt, Dec 7, 2008 IP
  7. Mark Oates

    Mark Oates Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    What's the purpose of the $? is it the first variable withwhich $1 is pulling a value?

    Without it it seems to be rewriting the variables correctly, nevertheless.

    oh and oddcomments, what's your "Search Engine for Search Engine Optimizers"? I don't get it. :p
     
    Mark Oates, Dec 9, 2008 IP