1

httpd.conf現在、ポート 80 からポート 8080 にすべてのリクエストを転送し、GlassFish アプリケーション サーバーによって処理されるように、ファイルに次のルールがあります。

<VirtualHost *:80>
    ServerAdmin admin@myserver.com
    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。3 番目のルールは、私が に行く場合にのみ機能しhttp://myserver.com/index.htmlます。

私は Apache のルールを書くのがまったくの初心者です。したがって、ここで私が間違っていたことを教えていただければ、非常に感謝しています:)。

アップデート:

次のルールは完全に機能します。

RewriteEngine On
RewriteRule ^/$ /page/index.html [R]
4

1 に答える 1

2

$URI の末尾を示すを追加する必要があります。

RewriteEngine On
RewriteRule ^/$ http://myserver.com/page/index.html

ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/

がないと$、正規表現が^/一致/page/index.htmlして再度リダイレクトされ、再び一致して再度リダイレクトされます。

于 2013-10-29T17:24:49.547 に答える