1.前往/etc/apache2/目錄,打開(kāi)httpd.conf文件
2.將文件中有關(guān)rewrite的注釋去掉

3.文件中在Directory里, 注釋掉AllowOverride none,改成AllowOverride All
并添加
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI}

4.重啟Apache
sudo apachectl restart
測(cè)試~

自動(dòng)跳轉(zhuǎn)https
