gpt4 book ai didi

apache - .htaccess 将 http 重定向到 https

转载 作者:行者123 更新时间:2023-12-03 05:19:45 24 4
gpt4 key购买 nike

我有一个旧网址 (www1.test.net),我想将其重定向到 https://www1.test.net
我已在我的网站上实现并安装了 SSL 证书。
这是我的旧文件.htaccess:

RewriteEngine On
RewriteRule !\.(js|gif|jpg|png|css|txt)$ public/index.php [L]
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ public/$1 [L]

如何配置我的 .htaccess 文件,以便网址自动重定向到 https
谢谢!

最佳答案

我使用以下命令成功将我域的所有页面从 http 重定向到 https:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

请注意,这将使用301“永久移动”重定向进行重定向,这将有助于转移您的 SEO 排名。

要使用302“暂时移动”进行重定向,请更改[R=302,L]

关于apache - .htaccess 将 http 重定向到 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13376219/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com