Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 通配符子域的透明重写/传递_Apache_Mod Rewrite_Apache2_Mod Auth Passthrough - Fatal编程技术网

Apache 通配符子域的透明重写/传递

Apache 通配符子域的透明重写/传递,apache,mod-rewrite,apache2,mod-auth-passthrough,Apache,Mod Rewrite,Apache2,Mod Auth Passthrough,我即将实现我的目标,但我无法找到解决问题的正确方法 我已经为我的通配符子域编写了以下规则: #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 her

我即将实现我的目标,但我无法找到解决问题的正确方法

我已经为我的通配符子域编写了以下规则:

#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]
#删除www。
重写cond%{HTTP_HOST}^www\.domain\.com$[NC]
重写规则^(.*)$http://domain\.com/$1[R=301,L]
#将子域重写为/club//
重写cond%{HTTP\u HOST}^(+)\.domain\.com$[NC]
重写规则^(.*)$http://domain.com/club/%1/$0[NC,L]
这是非常接近我的要求,即如果我去的网址是重写为

然而

我希望浏览器中的url看起来仍然像原始url

非常感谢

编辑:我尝试将PT添加到最终规则中,但不起作用,我得到一个400错误

EDIT2:对于任何感兴趣的人,我放弃了这一行查询,而是使用php读取子域中的文本。

如果www.example.com子域使用与example.com域相同的虚拟主机,您可以使用相对路径进行内部重写:

RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$ [NC]
RewriteCond $0 !^club/
RewriteRule ^(.*)$ club/%1/$0 [NC,L]
否则,您将需要一个代理:

RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/club/%1/$0 [NC,L,P]

谢谢,但是我第一个错误是500,第二个错误是404second@Vanthel:你在哪里使用那条规则?在文档根目录的.htaccess文件中?这是正确的,该规则是否可能以某种方式冲突(在文件的下面:RewriteRule.*index.php/$0[PT])