0
目前,我在我的httpd.conf
文件下面的规则从端口80上的所有请求转发到端口8080通过GlassFish应用服务器提供服务:如何将请求转发到另一个URL?
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName myserver.com
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass/http://localhost:8080/
ProxyPassReverse/http://localhost:8080/
</VirtualHost>
现在,我需要添加一个规则,使得所有的请求到http://myserver.com/
将被转发到http://myserver.com/page/index.html
,并且客户端的浏览器上的URL仍应显示为http://myserver.com/
。我尝试添加上述VirtualHost
内的规则如下:
RewriteEngine On
RewriteRule http://myserver.com/ http://myserver.com/page/index.html
或
RewriteEngine On
RewriteRule ^/ http://myserver.com/page/index.html
或
RewriteEngine On
RewriteRule ^/index.html http://myserver.com/page/index.html
然而,当我去http://myserver.com/
,浏览器有这个错误:This webpage has a redirect loop
。第三条规则只有在去http://myserver.com/index.html
时才可以使用。
我是Apache的写作规则的总noob。因此,如果你能告诉我我在这里做错了什么,我将非常感激:)。
UPDATE:
以下规则完美的作品:
RewriteEngine On
RewriteRule ^/$ /page/index.html [R]
谢谢! :d –