Subdomains auto redirect
on domain.tld we have different websites under default, f.e.
www.domain.tld/default/site_one , www.domain.tld/default/site_two, ......
We want a rewrite rule so that site_one.domain.tld will be redirected to the site www.domain.tld and the same for site_two and any other (new) site.
In stead of using virtual hosts we can use the follwing apache redirect rule which needs to be placed in the documenr root, in the file .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^w]*)\.domain\.tld$ [NC]
RewriteRule "(.*)" "http://www.domain.tld/default/%1" [NC]
</IfModule>
The condition is that the subdomian does not start with a 'w', if so the redirect will take place and traffic will be redirected to www.domain.tld/default/subdomain
ToDo is to create the match so that only www is not affected.