Apache rewrite based on subdomain

You should have a look at the URL Rewriting Guide from the apache documentation. The following is untested, but it should to the trick: RewriteCond %{HTTP_HOST} ^([^.]+)\.blah\.domain\.com$ RewriteRule ^/(.*)$ http://blah.domain.com/%1/$1 [L,R] This only works if the subdomain contains no dots. Otherwise, you’d have to alter the Regexp in RewriteCond to match any character which should … Read more

Virtualhost For Wildcard Subdomain and Static Subdomain

<VirtualHost *:80> DocumentRoot /var/www/app1 ServerName app1.example.com </VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/example ServerName example.com </VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/wildcard ServerName other.example.com ServerAlias *.example.com </VirtualHost> Should work. The first entry will become the default if you don’t get an explicit match. So if you had app.otherexample.com point to it, it would be caught be app1.example.com.