2017. 4. 26. 12:33 Linux Server/apache
[apache] rewrite 모듈을 이용한 http -> https 포워딩
[ apache rewrite 모듈을 이용한 http -> https 포워딩 ]
웹사이트 http 에서 https 자동으로 포워딩 하고 싶을때 rewrite 모듈을 이용하면 된다.
mod_ssl 과 rewrite 모듈이 설치가 되어 있어야 한다.
[apache rewrite 모듈 설치]
# cd /usr/local/src/APM-setup/httpd-2.4.3/modules/mappers -> 모듈을 설치하기 위해 컴파일 했던 위치로 이동
# /usr/local/apache/bin/apxs -a -i -c mod_rewrite.c
# vi /usr/local/apache/conf/httpd.conf -> 아래 설정 값 수정
LoadModule rewrite_module modules/mod_rewrite.so -> 해당 라인 주석 해제
AllowOverride none -> 해당 부분을 AllowOverride All 로 변경
[rewrite 설정 적용]
# vi /usr/local/apache/conf/extra/httpd-vhost.conf -> 해당 vhost에 아래내용 삽입하거나 , 아래처럼 홈디렉터리에 .htaccess 파일 만들어서 삽입
# vi /home/test/.htaccess -> 해당 홈 디렉토리에 .htaccess 파일 생성 하여 아래값 작성
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R,L]
아파치 재시작
'Linux Server > apache' 카테고리의 다른 글
[php 언어셋 문제] (0) | 2017.05.09 |
---|---|
[apache] cband 모듈설치 (0) | 2017.04.27 |
[apache] 모듈 userdir (0) | 2017.01.10 |
[apache] apache 소스설치 (2.4.3) (0) | 2016.09.21 |
[apache] mod_rewrite 설치 (0) | 2016.09.14 |