Redirect Sub domain to Root

Discussion in 'Apache' started by Silver89, Jul 21, 2010.

  1. #1
    If I have the following url:

    test.domain.com

    Then it will look for root files in: test.domain.com/file.php

    How can I change this so it looks for files in: domain.com/file.php

    I am using dynamic subdomains also which explains why I need this to happen, my code so far is:

    
    Options +FollowSymLinks
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} !^www\.domain\.com
    RewriteCond %{HTTP_HOST} ([^.]+)\.domain\.com
    RewriteCond %{REQUEST_URI} !^/user\.php$
    RewriteCond %{QUERY_STRING} !^username=.
    RewriteRule (.*) user.php?username=%1 [L]
    
    Code (markup):
     
    Silver89, Jul 21, 2010 IP