[아파치] Apache SSL https 리다이렉트 방법(+ 예외처리)
※본 문서는 Aapache2.4 기준으로 작성되었다.
Aapache에 SSL 적용후 https로 리다이렉팅(http로 접속했을때 강제로 https로 접속을 하게끔하는것)
방법을 소개한다.
1. 추가 경로
{apache instance home}/conf 아래 httpd.conf에 작성하거나
{apache instance home}/conf/extra httpd-vhost.conf 에 작성하면 된다.
(vhost폴더를 따로만들어서 사용할경우 해당폴더내의 conf파일에 작성하면된다)
2. 추가 내용
#SSL Rewrite
SSLProxyEngine On
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
</IfModule>
<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
3. 내용설명
#SSL Rewrite
SSLProxyEngine On
<IfModule mod_rewrite.c>
RewriteEngine On ->rewrite관련기능을 활성화 해준다.
RewriteCond %{HTTPS} off ->조건문으로 다음의 조건을(현재조건 https접속이 아닐경우)
충족시킬시 아래에 명시된 Rule의 행동을 한다
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L] -> 리다이렉트 할 url을 명시한다 [L]은 마침표 의미
</IfModule>
<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>