1.请确保Apache已经打开Mod_rewrite模块.
2.在网站根目录的.htaccess里加入以下内容
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
3.无需重启服务器,.htaccess文件修改后实时生效.
It's dangerous to go alone! Take this.
1.请确保Apache已经打开Mod_rewrite模块.
2.在网站根目录的.htaccess里加入以下内容
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
3.无需重启服务器,.htaccess文件修改后实时生效.