在 .htaccess 中强制使用 HTTPS 并避免 302 重定向
Force HTTPS and Avoid 302 Redirect in .htaccess
我想在我的站点中强制使用 HTTPS 并避免在 RewriteRule 中使用重定向 302。
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME}% !-d
RewriteCond %{REQUEST_FILENAME}% !-f
RewriteRule ^(.*)$ https://%{HTTP_HOST}/index.php [QSA,L]
我知道如果我使用 https:// 它会触发重定向,但是我如何强制使用 HTTPS 来保持安全协议?
提前致谢
RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (www\.)?mysite.com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME}% !-d
RewriteCond %{REQUEST_FILENAME}% !-f
RewriteRule ^(.*)$ index.php [QSA,L]
我想在我的站点中强制使用 HTTPS 并避免在 RewriteRule 中使用重定向 302。
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME}% !-d
RewriteCond %{REQUEST_FILENAME}% !-f
RewriteRule ^(.*)$ https://%{HTTP_HOST}/index.php [QSA,L]
我知道如果我使用 https:// 它会触发重定向,但是我如何强制使用 HTTPS 来保持安全协议?
提前致谢
RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (www\.)?mysite.com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME}% !-d
RewriteCond %{REQUEST_FILENAME}% !-f
RewriteRule ^(.*)$ index.php [QSA,L]