Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 将非HTTPS重定向到HTTPS_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess 将非HTTPS重定向到HTTPS

.htaccess 将非HTTPS重定向到HTTPS,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我试图强制非HTTPS访问者使用HTTPS,请参阅下面的代码 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] RewriteCond %{HTTPS} off RewriteRule (.*) https://%{SERVER_NAME}/%$1 [R,L] 它将example.com重定向到 我只想example.com重定向到 请帮助。颠倒顺序: RewriteEng

我试图强制非HTTPS访问者使用HTTPS,请参阅下面的代码

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/%$1 [R,L]
它将example.com重定向到 我只想example.com重定向到

请帮助。

颠倒顺序:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

您可以尝试以下操作:
RewriteCond%{SERVER\u PORT}80 RewriteRule^(.*)$https://%{SERVER\u NAME}/%$1[R,L]