Apache 将(代理)文件夹重定向到子域
我需要一个重写规则,它将获取一个文件夹(动态)并将其重写到子域,它还需要对用户(代理)透明。
以下是一些示例:
示例 1
http://admin.domain.com/a/foo
应代理至:
http://a.admin.domain.com/foo
示例 2
http://admin.domain.com/12345/foo
应代理至:
http://12345.admin.domain.com/foo
基本上,路径中的第一个文件夹用作子域,路径的其余部分则用作子域保持原样。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将其添加到文档根目录中的 .htaccess 文件中:
如果要将其添加到服务器配置或虚拟主机配置中,请在正则表达式前面添加一个“/”,使其看起来像这样:
^/( [^/]+)/(.*)$
。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:
^/([^/]+)/(.*)$
.