我正在尝试编写一个看起来与此类似的网址:
http://foo.domain.com/bar/fee/
对此:
http://IP:port/bar/fee/
这是我当前的代码:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^foo.domain.com/
RewriteRule ^(.*) http://IP:port/$1 [P]
但这不起作用,因此提出了这个问题。
我正在尝试编写一个看起来与此类似的网址:
http://foo.domain.com/bar/fee/
对此:
http://IP:port/bar/fee/
这是我当前的代码:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^foo.domain.com/
RewriteRule ^(.*) http://IP:port/$1 [P]
但这不起作用,因此提出了这个问题。
你不能path segment
在HTTP_HOST
变量中匹配。
使用此规则:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^foo\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://IP:port/$1 [P]
如果您不想要proxy
功能,请替换P
标志:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^foo\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://IP:port/$1 [L,R=301,NE]