我有域名foo.bar.example.com。 foo是bar.example.com下的许多子子域中的一个。 我需要捕获并redirect以“/ special /”开头的foo.bar.example.com上的所有链接。
我在.htaccess中使用了以下代码,将foo.bar.example.com/special/asdf成功redirect到special.example.com/foo/asdf。
RewriteCond %{HTTP_HOST} (.*?)\.bar\.example\.com RewriteRule ^/special/(.*)$ http://special.example.com/%1/$1 [L,NC,QSA]
真棒,一切正常。 有什么问题?
我有很多合作伙伴(this.that.com,silly.billy.com等),已经build立了CNAME的指向我的匹配子子域(that.bar.example.com,billy.bar.example.com等)。 我需要this.that.com/special/asdf也可以redirect到special.example.com/that/asdf,而不需要伙伴做任何额外的修改。
不幸的是,我目前还没有能力testing这个function。 从我所了解的mod_rewrite基于浏览器input的内容而不是它获取到的内容。 如果这是真的,那么我将无法使用我的域名命名标准? 我不能依靠我的合作伙伴来遵循类似的标准。 我怎样才能得到this.that.com/special/asdfredirect到special.example.com/that/asdf?