浣跨敤mod_rewrite妯″潡锛氬湪.htaccess鏂囦欢涓坊鍔犱互涓嬩唬鐮侊細
apache
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
杩欎細灏嗘墍鏈夐氳繃HTTP璁块棶鐨勮姹傞噸瀹氬悜鍒癏TTPS銆
浣跨敤Redirect鎸囦护锛氬湪.htaccess鏂囦欢涓坊鍔犱互涓嬩唬鐮侊細
apache
Redirect permanent / https://www.example.com/
杩欏皢鎶婃墍鏈変互HTTP鍗忚璁块棶鐨勮姹傛案涔呴噸瀹氬悜鍒癏TTPS銆
浣跨敤SSL/TLS閲嶅畾鍚戯細鍦.htaccess鏂囦欢涓坊鍔犱互涓嬩唬鐮侊細
apache
Header always set Content-Security-Policy "upgrade-insecure-requests"
杩欎細灏嗘墍鏈夋湭浣跨敤HTTPS鐨勮姹傞噸瀹氬悜鍒癏TTPS銆傝娉ㄦ剰锛岃繖绉嶆柟娉曢渶瑕佹湇鍔″櫒鏀寔CSP锛堝唴瀹瑰畨鍏ㄧ瓥鐣ワ級銆
鏃犺鎮ㄩ夋嫨鍝鏂规硶锛岄兘搴旂‘淇濆湪灏咹TTP閲嶅畾鍚戝埌HTTPS鏃朵娇鐢ㄦ案涔呴噸瀹氬悜锛301锛夛紝浠ヤ究姝g‘鍦颁紶閫扴EO鍊笺
浠ヤ笂灏辨槸.hatacess 鏂囦欢 http閲嶅畾鍚戝埌https鐨勮缁嗗唴瀹癸紝鏇村淇℃伅璇峰叧娉∣D浜戝叾瀹冪浉鍏虫枃绔狅紒