我有一个 Codeigniter 应用程序,它是在普通 http 上开发和测试的。现在,Apache 服务器已配置为所有页面都存储在启用了 SSL 的单个文件夹中。 SSL 证书已到位。当我使用“https://www”浏览网站时,它会重定向到“http://www”。
注意:我不需要使用 SSL 加载特定页面。我只需要所有页面都显示为 HTTPS。
我已经尝试了 Stack Overflow 上建议的解决方案,包括:
- 修改 .htaccess 文件以强制使用 HTTPS
- 设置
$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 会产生相同的错误。
有没有一种简单的方法可以在没有钩子(Hook)和 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/