www.subdomain.domain.com works on my site (how can i redirect it to non www)

Discussion in 'Site & Server Administration' started by touchAshley, Aug 9, 2009.

  1. #1
    i have my forums at http://forums.domain.com/

    I did a 301 redirect for http://www.domain.com/forums/ to the above url ^

    I just tried typing in www.forums.domain.com just to see if it would work (it doesnt work on dp) and it worked... How can I stop this and make it so that the www version of the sudomain redirects to http://forums.domain.com/ ?
     
    touchAshley, Aug 9, 2009 IP
  2. Guttu

    Guttu Peon

    Messages:
    728
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Goto your domain control panel and create a cname alias
    "www.forums" pointing to "forums.domain.com" without quotes of course.
     
    Guttu, Aug 9, 2009 IP
  3. touchAshley

    touchAshley Active Member

    Messages:
    1,762
    Likes Received:
    85
    Best Answers:
    0
    Trophy Points:
    90
    #3
    Thanks Guttu, but the below code seemed to do the trick for me.

    I put this in my .htaccess in my /forums directory to remove the www in www.forums.domain.com just in case anyone decides to type in that address, or link to it like that.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.+)$
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    Code (markup):
     
    touchAshley, Aug 9, 2009 IP
  4. Guttu

    Guttu Peon

    Messages:
    728
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That'll work too :)
     
    Guttu, Aug 9, 2009 IP