【发布时间】:2018-07-23 19:23:12
【问题描述】:
我的前端服务器由 Apache 2.4 处理。
我希望在访问http://198.51.100.13/site1/ 时,它会自动将流量重定向到我服务器的端口 1001,如下所示:
<VirtualHost *:80>
ServerName 198.51.100.13
<Directory "/">
Require all granted
</Directory>
RewriteEngine On
RewriteRule ^/site1(.*)$ http://localhost:1001$1 [P,L]
RewriteRule ^/site2(.*)$ http://localhost:1002$1 [P,L]
RewriteRule ^/site3(.*)$ http://localhost:1003$1 [P,L]
</VirtualHost>
问题:打开http://198.51.100.13/site1/时出现此错误:
403:禁止
您无权访问此服务器上的 /areallybigpage。
另一方面,如果我使用http://198.51.100.13:1001/,它可以工作(在端口 1001 上有一个 Python 服务器,但这对于这个问题并不重要)。
如何解决?
【问题讨论】:
-
你试过把
RewriteRule ^/site2(.*)$ http://localhost:1002$1 [P,L]改成`198.51.100.13:1001, i,e, use the IP instead oflocalhost`的格式吗? -
@ildflue 是的,同样的问题。
标签: apache mod-rewrite apache2 virtualhost apache2.4