본문 바로가기

WEB/Apache,OHS

[Apache,OHS] http로 접속 시 https로 리다이렉트

httpd.conf 파일에 설정한다

 

rewrite_module 이 필요하다.

주석처리 되어있다면 주석을 해제한다

 

httpd.conf 파일 맨 하단에 아래와 같이 추가한다

#HTTPS redirect
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}:443%{REQUEST_URI} [R=301,L]

 

반대로 https 접속시 http로 리다이렉트 해야 하는 경우

https://blog.truds.kr/510/

#HTTP redirect
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{SERVER_NAME}:80%{REQUEST_URI} [R=301,L]