Apache 2.4.6では、http://A.org/foo
とhttps://A.org/foo
からhttps://B.org/foo
にリクエストをリダイレクトしたいと思います。httpとhttpsの両方のリクエストを新しいホストにリダイレクトする
私は、次のディレクティブを使用しています:私はhttp://A.org/foo
にアクセスすると、これはhttps://B.org/foo
(正しい)にリダイレクト
<VirtualHost 1.2.3.4:80>
ServerName B.org
ServerAlias A.org
RewriteEngine on
RewriteCond %{HTTP_HOST} !^B.org$
RewriteRule ^/(.*)$ https://B.org/$1 [R=permanent,L]
</VirtualHost>
<VirtualHost 1.2.3.4:443>
ServerName B.org
ServerAlias A.org
RewriteEngine on
RewriteCond %{SERVER_PORT} ^443(s)
RewriteCond %{HTTP_HOST} !^B.org$
RewriteRule ^/(.*)$ https://B.org/$1 [R=permanent,L]
</VirtualHost>
。
https://A.org/foo
にアクセスすると、https://B.org/foo
がロードされますが、URLは書き換えられません。そのため、WebブラウザからSSL証明書ドメインの不一致エラーが発生します。
VirtualHost
ディレクティブにURLが書き換えられないようにする何か問題がありますか?
'RewriteCond%{SERVER_PORT}^443(s)'行をコメントアウトし、ブラウザのキャッシュをクリアした後に再テストします。 – anubhava
私は同じ動作をします。 –