Apache で https:// へのリクエストを http:// にリダイレクトする




Apache で https:// へのリクエストを http:// にリダイレクトする方法は次の通り。

CentOS:2.6.18-8.el5
Apache:2.2.3
を使用しました。

/etc/httpd/conf.d/ssl.conf を以下のように編集する。

<VirtualHost> と </VirtualHost> の間に以下を追記する。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.test.example(.*)
RewriteRule ^(.*)?$ http://www.test.example$1 [L,R]
</IfModule>

設定の反映は httpd の再起動。

これでブラウザで https://www.test.example へアクセスすると
http://www.test.example にリダイレクトされる。

念のため、
https://www.test.example/test/test.html へのアクセスも
https://www.test.example/test/test.html にリダイレクトされることを確認した。