.htaccess 文件中的 https 重定向代码

问题描述 投票:0回答:0
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)?$ https://example.com/$1 [L,R]
RewriteCond %{SERVER_PROTOCOL} ^https [NC]
RewriteRule .* - [F]

这个 .htaccess 文件在我开始工作的服务器上。这很好用。但我不明白最后两行。这意味着什么?为了什么? 谢谢。

我尝试了下面的方法,现在看来效果很好。

RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)?$ https://example.com/$1 [L,R]
apache .htaccess url-rewriting
© www.soinside.com 2019 - 2024. All rights reserved.