【发布时间】:2015-05-15 14:50:15
【问题描述】:
我正在尝试在 apache 中处理带有 url 掩码的通配符子域。 正确的重写规则应该达到以下几点:
http://demo.system.dev 到 to http://system.dev?subdomain=demo
http://sample.system.dev/user/edit/100 到 to http://system.dev/user/edit/100?subdomain=sample
http://debug.system.dev/project/edit/new 到 to http://system.dev/project/edit/new?subdomain=debug
到目前为止,我的 .htaccess 中有以下规则
RewriteCond %{HTTP_HOST} ^(.*)\.system\.dev
RewriteRule ^(.*?)$ http://system.dev%{REQUEST_URI}?subdomain=%1 [L]
它看起来工作正常,只是浏览器 url 也发生了变化。我希望浏览器 url 保持不变并在内部路由请求,但我不确定如何实现。
【问题讨论】:
-
@anubhava其实是同一个域,站点可用文件是一样的
标签: apache .htaccess mod-rewrite url-rewriting