Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.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
Php Mod_重写匹配子域和查询字符串_Php_.htaccess_Apache - Fatal编程技术网

Php Mod_重写匹配子域和查询字符串

Php Mod_重写匹配子域和查询字符串,php,.htaccess,apache,Php,.htaccess,Apache,我目前正在修改将domain.com/a/123/abc改写为page.php?this=123&that=abc: RewriteRule ^a/([^/]+)/([^/]+)/?$ page.php?this=$1&that=$2 [L] 另外,我现在想把a.domain.com/123/abc改写成page.php?this=123&that=abc 因此a.domain.com/123/abc和domain.com/a/123/abc都将重定向到page.php?this=12

我目前正在修改将
domain.com/a/123/abc
改写为
page.php?this=123&that=abc

RewriteRule ^a/([^/]+)/([^/]+)/?$ page.php?this=$1&that=$2 [L]
另外,我现在想把
a.domain.com/123/abc
改写成
page.php?this=123&that=abc

因此
a.domain.com/123/abc
domain.com/a/123/abc
都将重定向到
page.php?this=123&that=abc

我的问题是匹配子域和查询字符串。这是我一直在做的,但它仍然没有被正确重写

RewriteCond %{HTTP_HOST} ^a\.domain\.com/ [NC]
RewriteCond %{QUERY_STRING} /([^/]+)/([^/]+)/?$ [NC]
RewriteRule ^(.*) /a/$1/$2 [L]

请注意,已设置通配符域(*.domain.com)。只是htaccess mod_重写失败。

是您的
RewriteCond
上的尾部
/

RewriteCond %{HTTP_HOST} ^a\.domain\.com/
应该是

RewriteCond %{HTTP_HOST} ^a\.domain\.com

没有,但是去掉它没有什么区别