gpt4 book ai didi

php - 将所有带有 http 的请求重定向到 https

转载 作者:可可西里 更新时间:2023-11-01 17:34:34 24 4
gpt4 key购买 nike

我需要将所有使用 http 的请求重定向到 https。我很难处理 php header 。有什么完美的方法吗?

最佳答案

您可以使用 .htaccess 将用户重定向到不同的 URL。在 www 文件夹中包含一个具有以下规则的 .htaccess 文件,以将传入流量从 HTTP 定向到 HTTPS

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

关于php - 将所有带有 http 的请求重定向到 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35389408/

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