通配符子域的透明重写/传递
我即将实现我的目标,但我无法想出正确的解决方案来解决我的问题。
我为我的通配符子域编写了以下规则:
#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/here
但是
我希望浏览器中的网址仍然看起来像原始网址
提前非常感谢
编辑< /strong>:我尝试将 PT 添加到最终规则中,但这不起作用,我收到 400 错误
EDIT2:对于任何感兴趣的人,我放弃了这一行查询,而是使用 php 来读取子域中的文本。
I am close to achieving my goal but I cannot come up with the correct solution to my problem.
I have written the following rules for my wildcard subdomains:
#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]
This is desperately close to what I require, ie if I go to http://alpha.domain.com/some/string/here the URL is rewritten to http://domain.com/club/alpha/some/string/here
however
I would like the url in browser to still look like the original url
Many thanks in advance
EDIT: I have tried just adding PT to the final rule but that doesn't work, I get a 400 error
EDIT2: For anyone interested, I abandoned this line of enquiry and instead used php to read the text in the subdomain.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 www.example.com 子域与 example.com 域使用相同的虚拟主机,您可以使用相对路径进行内部重写:
否则您将需要代理:
If the www.example.com subdomain uses the same virtual host as the example.com domain, you can just use an internal rewrite by using a relative path:
Otherwise you will need a proxy: