將 HTTP 重導至 HTTPS in XAMPP
1. 修改:c:\xampp\apache\conf\extra\httpd-xampp.conf (將區塊內的設定資料,直接加入到 httpd-xampp.conf 底部)
<IfModule mod_rewrite.c>
RewriteEngine On# Redirect /xampp folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} xampp
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]# Redirect /dashboard folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} dashboard
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]# Redirect /phpMyAdmin folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} phpmyadmin
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]# Redirect /security folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} security
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]# Redirect /webalizer folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} webalizer
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]</IfModule>
其中 RewriteCond %{REQUEST_URI} xampp 內的 xampp 為網站虛擬目錄名稱,可以修改為分訂名稱,
如:RewriteCond %{REQUEST_URI} wordpress,
其網址為 https://127.0.0.1/wordpress
2. 重新啟動 apache
3. 測試
資料來源:XAMPP將HTTP重新導向到HTTPS