I need a rewrite rule that will take a folder (dynamic) and rewrite it to a subdomain, it also needs to be transparent to the user (proxy).
Here are some examples:
Example 1
http://admin.domain.com/a/foo
Should proxy to:
http://a.admin.domain.com/foo
Example 2
http://admin.domain.com/12345/foo
Should proxy to:
http://12345.admin.domain.com/foo
Basically the first folder in the path is being used as the subdomain and the rest of the path is left as is.
Try adding this to the .htaccess file in your document root:
If you want to add this to your server config or vhost config, add a “/” in front of the regex so that it looks like this:
^/([^/]+)/(.*)$.