Bogus Subdomains Point To My Homepage

Discussion in 'Apache' started by atounia, Mar 13, 2006.

  1. #1
    How do I setup a permanent redirect from "www.subdomain.domain.com" to "subdomain.domain.com" ?

    Also, is this something that can be done in the .htaccess file of the root directory, or do I need to create .htaccess files for each one of my subdomain folders?
     
    atounia, Mar 13, 2006 IP
  2. Slapyo

    Slapyo Well-Known Member

    Messages:
    266
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    This will put remove the www. from your domains. If someone goes to www.domain.com it will now be domain.com ... if someone goes to www.subdomain.domain.com it will now be subdomain.domain.com. This will always remove the www. from your URL. Place the .htaccess in your root folder.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.+)$
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    Code (markup):
     
    Slapyo, Mar 15, 2006 IP