素肌にサスペンダー

個人的な備忘と日記

.htaccessで、httpsにURLを正規化する

もしhttpで訪れても、httpsにURLをリダイレクトさせたい場合、.htaccessに以下を記述する

RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

参考

htaccess.cman.jp