개발자의 끄적끄적

[php/codeigniter] redirect http to https in .htaccess 본문

개발/php

[php/codeigniter] redirect http to https in .htaccess

효벨 2021. 3. 5. 03:00
728x90
반응형

[php/codeigniter] redirect http to https in .htaccess

 

 

코드이그나이터로 프로젝트를 완료 후

 

서버에 옮기고 나면 https, 즉 ssl 설정을 해야합니다.

 

하지만, apache 설정에서 ssl 을 정상적용했다 하더라도,

 

redirect 설정은 추가적으로 작업을 해야 합니다.

 

그럴때 .htaccess 에서 redirect 할 수 있는 내용을 공유하고자 합니다.

 

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTPS} !=on
 RewriteCond $1 !^(index\.php|images|robots\.txt)
 RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ /index.php/$1
</IfModule>

 

위 내용 처럼

 

.htaccess 파일을 설정 후

 

저장하시고 http 로 접근해서 보시면 정상적으로 redirect 되는 것을

 

확인할 수 있습니다!

 

참고들 하세요!

반응형
Comments