如何让 CodeIgniter 使用 SSL 加载特定页面? [英] How can I have CodeIgniter load specific pages using SSL?

查看:24
本文介绍了如何让 CodeIgniter 使用 SSL 加载特定页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让 CodeIgniter 使用 SSL 加载特定页面?我有一个 apache2/mode_ssl 服务器.mod_ssl 使用与非安全页面不同的文档根.例如,https(端口 443)将提供 /var/www/ssl_html/ 之外的页面,而 http(端口 80)将提供 /var/www/html/ 之外的页面>.我如何让 CodeIgniter 在这个设置中发挥良好的作用?

How can I have CodeIgniter load specific pages using SSL? I have an apache2/mode_ssl server. mod_ssl uses a different document root than non-secure pages. For example, https (port 443) would serve pages out of /var/www/ssl_html/ And http (port 80) serves pages out of /var/www/html/. How would I get CodeIgniter to play nice with this setup?

推荐答案

解决这个问题的方法很少.

There are few ways to tackle this.

选项 1:

我可能会将代码部署到两个文件夹中,然后在文件:/system/application/config/config.php 中,将您的页面设置为:

I would probably have the code deployed to both folders, then in the file: /system/application/config/config.php, set your page to:

$config['base_url'] = "http://www.yoursite.com/"; 

$config['base_url'] = "https://www.yoursite.com/";

然后在您的非 ssl VirtualHost 文件夹中,将您的配置设置为按文件夹将受保护的页面重定向到 SSL 站点:

Then in your non-ssl VirtualHost folder, set your config to redirect protected pages by folder to the SSL site:

RedirectPermanent /sslfolder https://www.yoursite.com/sslfolder

选项 2:

将所有内容发送到 SSL 并将所有代码保存在一个文件夹中

Send everything to SSL and keep all your code in one folder

/system/application/config/config.php,将你的页面设置为:

/system/application/config/config.php, set your page to:

$config['base_url'] = "https://www.yoursite.com/";

其他选项

有一些更hacky的方法可以通过 header() 重定向等来做到这一点,但我认为您不想为此选项维护不同的代码库.我不建议这样做,但您可以执行以下操作:

There are some more hacky ways to do this with header() redirects, etc. but I don't think you want to maintain different code bases for this option. I don't recommend this but you could do something like:

$config['base_url'] = "http://" . $_SERVER['http_host'] . "/";

这篇关于如何让 CodeIgniter 使用 SSL 加载特定页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆