Etc / / 2020. 2. 24. 13:09

무조건 https, www 떼기

728x90

RewriteEngine On

 

# ssl

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]

 

# non-www

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

 

ssl을 적용하게 되면 강제로 https로 이동하게 하는 경우가 있는데 그럴 때 위 ssl 부분만 사용하면 됩니다.

혹시나 홈페이지에서 www를 떼고 싶다면 위 non-www 부분만 사용하면 됩니다.

 

# force https for sub domain

RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

반응형