我有一个名为exmaple的网站,其中有很多子域
i have site called exmaple have a lot of subdomains
test1 , test2 , test2.example我该如何重定向具有确切子域名但又重定向到另一个域名的子域名
how could i redirect subdomains with exact subdomain but to another domain name for example
test1 , test2 , test3.example谢谢
推荐答案使用%1%2等从RewriteCond中获取正则表达式匹配组.
Use %1 %2 etc. to grab regex-match groups from the RewriteCond.
您可能知道,$ 1 $ 2匹配RewriteRule中的正则表达式组
As you probably know, $1 $2 matches regex groups from the RewriteRule
在我的脑海中,使用mod_rewrite活动非常简单:
Off the top of my head, this is pretty straightforward with mod_rewrite active:
RewriteEngine On RewriteCond %{REQUEST_HOST} (.+)\.example\ RewriteRule (.*) %1.example$1 [R,QSA]这假定您正在从单个虚拟主机提供所有这些子域,但是如果不是,则可以将此规则集分别复制到每个用户的配置或.htaccess中.
This assumes that you are serving all those subdomains from a single virtual host, but if you aren't, you can just copy this ruleset into each one's config or .htaccess individually.
更多推荐
重定向子域到相同的子域名但不同的域名
发布评论