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

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -