我接近实现我的目标,但我无法为我的问题找到正确的解决方案。
我为通配符子域编写了以下规则:
#remove www.
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain\.com/$1 [R=301,L]
#rewrite subdomains to /club/<clubname as defined by subdomain>/<whatever was here before>
RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/club/%1/$0 [NC,L]
这非常接近我的要求,即如果我转到http://alpha.domain.com/some/string/here,则 URL 将被重写为http://domain.com/club/alpha/some/string/这里
然而
我希望浏览器中的网址仍然看起来像原始网址
提前谢谢了
编辑:我尝试将 PT 添加到最终规则中,但这不起作用,我收到 400 错误
EDIT2:对于任何有兴趣的人,我放弃了这行查询,而是使用 php 来读取子域中的文本。