redirecting all sub-domains

Discussion in 'Apache' started by just-4-teens, Nov 18, 2007.

  1. #1
    is there a way of redirecting all sub-domains to the main domain?
     
    just-4-teens, Nov 18, 2007 IP
  2. hostingonweb

    hostingonweb Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Create a .htaccess file under your subdomain and add this:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^subdomain.maindomain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.subdomain.maindomain.com$
    RewriteRule ^(.*)$ http(colon)(slash)(slash)maindomain.com [R=301,L]

    Remember to replace (slash) with / and (colon) with :
     
    hostingonweb, Nov 19, 2007 IP