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

查看:171
本文介绍了我如何让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:

您的所有代码都位于一个文件夹

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/";

其他选项

有一些更复杂的方法来做这个与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天全站免登陆