Removing Subdomain - Want to use htaccess to redirect

Discussion in 'Apache' started by lbalance, Jan 24, 2008.

  1. #1
    I have a forum in which it is mostly used as www.domain.com/forum but I set up a subdomain for it last year so some pages got indexed by google as forum.domain.com. Instead of just removing the subdomain and having the indexed pages go to a 404, I would like htaccess to redirect to proper thread.

    Current URL:
    forum.domain.com/index.php/topic,1234.0.html

    Needs to be:
    www.domain.com/forum/index.php/topic,1234.0.html


    Thanks
     
    lbalance, Jan 24, 2008 IP
  2. norbert

    norbert Guest

    Messages:
    61
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Not tested but it should work like this:
    
    RewriteCond %{HTTP_HOST} ^forum\.domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/forum/$1 [R=301,L]
    
    Code (markup):
     
    norbert, Jan 25, 2008 IP