gpt4 book ai didi

php - 如何为 HTTPS (SSL) 配置 Codeigniter?

转载 作者:太空宇宙 更新时间:2023-11-03 14:50:16 24 4
gpt4 key购买 nike

我有一个在普通 http 上开发和测试的 Codeigniter 应用程序。现在 Apache 服务器已配置为所有页面都存储在启用 SSL 的单个文件夹中。 SSL 证书已到位。当我使用“https://www”浏览网站时,它会重定向到“http://www”。

注意:我不需要使用 SSL 加载特定页面。我只需要所有页面都显示为 HTTPS

我已经尝试了 Stack Overflow 上建议的解决方案,包括:

  1. 修改 .htaccess 文件以强制使用 HTTPS
  2. 设置 $config['base_url'] = "https://www.yoursite.com/";

当我同时尝试上述方法时,Firefox 出现以下错误:

The page isn't redirecting properly. Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

许多 Stack Overflow 贡献者建议这应该仅由 Apache 处理。这对我来说很有意义,但是通过 .htaccess 强制使用 HTTPS 会产生同样的错误。

有没有一种无需 hooks 和 SSL Helpers 等的简单方法?

最佳答案

这个答案有点晚(阅读:很多),但你可以使用这个 hook我做了(5 分钟前),它会重定向到您的 HTTPS 网站并设置一些 header 。

我将它与这个 .htaccess 文件一起使用:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L]

关于php - 如何为 HTTPS (SSL) 配置 Codeigniter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34990355/

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