Question

Can you suggest a set of Apache rewrite rules to convert domain.com/app to app.domain.com? The rewrite rules should be valid for any app name and any sub path specified. For example, the script should be able to convert domain.com/otherapp/view.do to otherapp.domain.com/view.do in a generic fashion. Much appreciate.

No correct solution

OTHER TIPS

RewriteCond %{HTTP_HOST} domain\.com [NC]
RewriteRule ^/([A-Za-z0-9-]+)/(.*)$ http://$1.domain.com/$2 [L,R]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top