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 –