1

我正在尝试编写一个看起来与此类似的网址:

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]

但这不起作用,因此提出了这个问题。

4

1 回答 1

1

你不能path segmentHTTP_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]
于 2013-11-13T17:04:55.627 回答