WEB - Apache 계열/각종 설정
[Apache,OHS] http로 접속 시 https로 리다이렉트
KeuangKuo
2022. 10. 12. 14:18
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로 리다이렉트 해야 하는 경우
#HTTP redirect
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{SERVER_NAME}:80%{REQUEST_URI} [R=301,L]