apache - Redirecting subdomains to their corresponding folders -
is possible configure .htaccess subdomain redirected it's corresponding folder without need edit .htaccess file every time want add subdomain? how?
foo.domain.com -> /subdomains/foo bar.domain.com -> /subdomains/bar anything.domain.com/file.txt -> /subdomains/anything/file.txt thanks!
you can use rule in site root .htaccess:
rewriteengine on rewritecond %{http_host} ^((?!www).+)\.domain\.com$ [nc] rewriterule ^((?!subdomains/).*)$ subdomains/%1/$1 [l,nc]
Comments
Post a Comment