子域作为mod_rewrite中的变量 [英] Sub-domain as variable in mod_rewrite
本文介绍了子域作为mod_rewrite中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试基于子域进行mod-rewrite.如何获取子域并将其附加到新域的末尾?
I am trying to mod-rewrite based on a sub-domain. How do I take the subdomain and append it to the end of my new domain?
示例:
RewriteCond %{HTTP_HOST} ^users\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/?subdomain=[variable for sub] [L]
如何使用户"进入[sub变量]?
How do I get 'users' into [variable for sub]?
推荐答案
最后一个RewriteCond
中的匹配项存储为%N,因此您可以执行以下操作:
Matches from the last RewriteCond
are stored as %N so you can do this:
RewriteCond %{HTTP_HOST} ^(users)\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/?subdomain=%1 [L]
这篇关于子域作为mod_rewrite中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文