<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: SSL (HTTPS) URLs and CodeIgniter</title>
	<atom:link href="http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/feed/" rel="self" type="application/rss+xml" />
	<link>http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
	<description>Courage to do something...</description>
	<lastBuildDate>Thu, 12 Apr 2012 10:00:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: prog3712</title>
		<link>http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/comment-page-1/#comment-4940</link>
		<dc:creator>prog3712</dc:creator>
		<pubDate>Mon, 05 Dec 2011 17:24:32 +0000</pubDate>
		<guid isPermaLink="false">http://sajjadhossain.com/?p=55#comment-4940</guid>
		<description>Great!!! It works perfectly!!
The Max Fellows solution works great for me.</description>
		<content:encoded><![CDATA[<p>Great!!! It works perfectly!!<br />
The Max Fellows solution works great for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohammad Sajjad Hossain</title>
		<link>http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/comment-page-1/#comment-3429</link>
		<dc:creator>Mohammad Sajjad Hossain</dc:creator>
		<pubDate>Wed, 18 Aug 2010 17:43:16 +0000</pubDate>
		<guid isPermaLink="false">http://sajjadhossain.com/?p=55#comment-3429</guid>
		<description>I have posted &lt;a href=&quot;http://sajjadhossain.com/2010/08/18/ssl-https-urls-and-codeigniter-extending-the-core/&quot; rel=&quot;nofollow&quot;&gt;SSL (HTTPS) URLs and CodeIgniter (Extending the core)&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>I have posted <a href="http://sajjadhossain.com/2010/08/18/ssl-https-urls-and-codeigniter-extending-the-core/" rel="nofollow">SSL (HTTPS) URLs and CodeIgniter (Extending the core)</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Gates</title>
		<link>http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/comment-page-1/#comment-3362</link>
		<dc:creator>Sean Gates</dc:creator>
		<pubDate>Sat, 10 Jul 2010 03:56:48 +0000</pubDate>
		<guid isPermaLink="false">http://sajjadhossain.com/?p=55#comment-3362</guid>
		<description>@Mohammed Yes, please change this post so show EXTENDING the helper (url_helper.php) and core (config.php) files, instead of editing them.  I would hate new CI programmers to come here and do it the way it is shown in your post.

Otherwise, thank you for your code! It was very helpful!</description>
		<content:encoded><![CDATA[<p>@Mohammed Yes, please change this post so show EXTENDING the helper (url_helper.php) and core (config.php) files, instead of editing them.  I would hate new CI programmers to come here and do it the way it is shown in your post.</p>
<p>Otherwise, thank you for your code! It was very helpful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pk</title>
		<link>http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/comment-page-1/#comment-2653</link>
		<dc:creator>pk</dc:creator>
		<pubDate>Thu, 28 Jan 2010 11:20:11 +0000</pubDate>
		<guid isPermaLink="false">http://sajjadhossain.com/?p=55#comment-2653</guid>
		<description>Here&#039;s a simple &lt;a href=&quot;http://it.euphoriatwentythree.com/web-development/codeigniter/codeigniter-ssl-https-helper/&quot; rel=&quot;nofollow&quot;&gt;CodeIgniter SSL (HTTPS) Helper&lt;/a&gt; which i wrote.</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a simple <a href="http://it.euphoriatwentythree.com/web-development/codeigniter/codeigniter-ssl-https-helper/" rel="nofollow">CodeIgniter SSL (HTTPS) Helper</a> which i wrote.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max Fellows</title>
		<link>http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/comment-page-1/#comment-2265</link>
		<dc:creator>Max Fellows</dc:creator>
		<pubDate>Thu, 03 Dec 2009 04:35:23 +0000</pubDate>
		<guid isPermaLink="false">http://sajjadhossain.com/?p=55#comment-2265</guid>
		<description>Thanks Mohammad and Mahbub -- I recently used this for a school project and it works great; I extended the base url_helper as Martin suggested.

One other thing that came in handy was overriding CI&#039;s base_url() method in MY_url_helper; other libraries like Template call base_url() when you do things like add_js() or add_css(), which causes warnings to pop up in IE if you&#039;re on a secure page.  This was the fix:

&lt;pre lang=&quot;php&quot;&gt;
function base_url() {
   $framework =&amp; get_instance();

   if (isset($_SERVER[&#039;HTTPS&#039;])) {
      return $framework-&gt;config-&gt;slash_item(&#039;secure_base_url&#039;);
   } else {
      return $framework-&gt;config-&gt;slash_item(&#039;base_url&#039;);
   }
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Thanks Mohammad and Mahbub &#8212; I recently used this for a school project and it works great; I extended the base url_helper as Martin suggested.</p>
<p>One other thing that came in handy was overriding CI&#8217;s base_url() method in MY_url_helper; other libraries like Template call base_url() when you do things like add_js() or add_css(), which causes warnings to pop up in IE if you&#8217;re on a secure page.  This was the fix:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> base_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$framework</span> <span style="color: #339933;">=&amp;</span> get_instance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTPS'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #000088;">$framework</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">slash_item</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'secure_base_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #000088;">$framework</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">slash_item</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'base_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Mohammad Sajjad Hossain</title>
		<link>http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/comment-page-1/#comment-2113</link>
		<dc:creator>Mohammad Sajjad Hossain</dc:creator>
		<pubDate>Tue, 29 Sep 2009 03:55:14 +0000</pubDate>
		<guid isPermaLink="false">http://sajjadhossain.com/?p=55#comment-2113</guid>
		<description>Martin, thanks for your correction and suggestions. I was thinking to upgrade the code as you said because I myself faced this problem while upgrading to latest CI version. I am a little bit busy now but I will work on it and share with others.</description>
		<content:encoded><![CDATA[<p>Martin, thanks for your correction and suggestions. I was thinking to upgrade the code as you said because I myself faced this problem while upgrading to latest CI version. I am a little bit busy now but I will work on it and share with others.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Evans</title>
		<link>http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/comment-page-1/#comment-2110</link>
		<dc:creator>Martin Evans</dc:creator>
		<pubDate>Tue, 29 Sep 2009 01:56:05 +0000</pubDate>
		<guid isPermaLink="false">http://sajjadhossain.com/?p=55#comment-2110</guid>
		<description>Thanks for posting this! It helped me out on a project.

I should point out there a couple of things that need to be fixed. In your code above, the last line of the function secure_anchor() in your url helper is missing a couple of single quotes. It should read:
&lt;pre lang=&quot;php&quot;&gt;
return &#039;&lt;a href=&quot;&#039;.$secure_site_url.&#039;&quot; rel=&quot;nofollow&quot;&gt;&#039;.$title.&#039;&lt;/a&gt;&#039;;
&lt;/pre&gt;
Also, it would be better not to edit the core CI files. One day someone else might upgrade CI and your ssl suddenly doesn&#039;t work!. Instead put the url_helper code in a file called MY_url_helper.php and store it in system/application/helpers/

Likewise, instead of adding code to the core Config.php library, put it in system/application/libraries/MY_Config.php - and follow the instructions for extending native libraries found at this url:

http://codeigniter.com/user_guide/general/creating_libraries.html

in MY_Config.php you would wrap the function with this code:
&lt;pre lang=&quot;php&quot;&gt;
class MY_Config extends CI_Config {

}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Thanks for posting this! It helped me out on a project.</p>
<p>I should point out there a couple of things that need to be fixed. In your code above, the last line of the function secure_anchor() in your url helper is missing a couple of single quotes. It should read:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$secure_site_url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; rel=&quot;nofollow&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">;</span></pre></div></div>

<p>Also, it would be better not to edit the core CI files. One day someone else might upgrade CI and your ssl suddenly doesn&#8217;t work!. Instead put the url_helper code in a file called MY_url_helper.php and store it in system/application/helpers/</p>
<p>Likewise, instead of adding code to the core Config.php library, put it in system/application/libraries/MY_Config.php &#8211; and follow the instructions for extending native libraries found at this url:</p>
<p><a href="http://codeigniter.com/user_guide/general/creating_libraries.html" rel="nofollow">http://codeigniter.com/user_guide/general/creating_libraries.html</a></p>
<p>in MY_Config.php you would wrap the function with this code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> MY_Config <span style="color: #000000; font-weight: bold;">extends</span> CI_Config <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Mahbub</title>
		<link>http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/comment-page-1/#comment-1797</link>
		<dc:creator>Mahbub</dc:creator>
		<pubDate>Wed, 27 May 2009 11:39:27 +0000</pubDate>
		<guid isPermaLink="false">http://sajjadhossain.com/?p=55#comment-1797</guid>
		<description>Yes, true that links you can build both for http and https. But Normally in some pages we want to make sure that user can&#039;t but use the ssl url. So you put the helper function  ssl_redirect() in the controller which will redirect 301 to the same url but with ssl. Like in payment pages we want to make sure that it&#039;s not http but https. Perhaps both we&#039;d both your and my solution as needed.</description>
		<content:encoded><![CDATA[<p>Yes, true that links you can build both for http and https. But Normally in some pages we want to make sure that user can&#8217;t but use the ssl url. So you put the helper function  ssl_redirect() in the controller which will redirect 301 to the same url but with ssl. Like in payment pages we want to make sure that it&#8217;s not http but https. Perhaps both we&#8217;d both your and my solution as needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohammad Sajjad Hossain</title>
		<link>http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/comment-page-1/#comment-1792</link>
		<dc:creator>Mohammad Sajjad Hossain</dc:creator>
		<pubDate>Fri, 22 May 2009 01:13:43 +0000</pubDate>
		<guid isPermaLink="false">http://sajjadhossain.com/?p=55#comment-1792</guid>
		<description>Thanks Mahbub for sharing. 

But I don&#039;t agree with &quot;So don’t need the secure anchor&quot;. Your solution will make all anchors secure which is good for 100% secure site.

Think of a situation, you have a secure page and in that page you need some links with &quot;http&quot;. Again in a &quot;http&quot; page you need some links with &quot;https&quot;. In these situations my solution works fine.</description>
		<content:encoded><![CDATA[<p>Thanks Mahbub for sharing. </p>
<p>But I don&#8217;t agree with &#8220;So don’t need the secure anchor&#8221;. Your solution will make all anchors secure which is good for 100% secure site.</p>
<p>Think of a situation, you have a secure page and in that page you need some links with &#8220;http&#8221;. Again in a &#8220;http&#8221; page you need some links with &#8220;https&#8221;. In these situations my solution works fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahbub</title>
		<link>http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/comment-page-1/#comment-1790</link>
		<dc:creator>Mahbub</dc:creator>
		<pubDate>Thu, 21 May 2009 10:14:22 +0000</pubDate>
		<guid isPermaLink="false">http://sajjadhossain.com/?p=55#comment-1790</guid>
		<description>I have base url dynamically defined  in my apps as 
&lt;pre lang=&quot;php&quot;&gt;
$config[&#039;host_url&#039;] = ((isset($_SERVER[&#039;HTTPS&#039;]) &amp;&amp; $_SERVER[&#039;HTTPS&#039;] == &quot;on&quot;) ? &quot;https&quot; : &quot;http&quot;);
$config[&#039;host_url&#039;] .= &quot;://&quot;.$_SERVER[&#039;HTTP_HOST&#039;];
$config[&#039;base_url&#039;] = $config[&#039;host_url&#039;] . str_replace(basename($_SERVER[&#039;SCRIPT_NAME&#039;]),&quot;&quot;,$_SERVER[&#039;SCRIPT_NAME&#039;]);
&lt;/pre&gt;

AND for SSL redirect I use a utility helper 

&lt;pre lang=&quot;php&quot;&gt;
if (! function_exists(&#039;ssl_redirect&#039;))
{
    function ssl_redirect()
    {
        if ($_SERVER[&quot;SERVER_PORT&quot;] != 443)
        {
            redirect(str_replace(&quot;http://&quot;, &quot;https://&quot; , current_url()), &quot;refresh&quot;);
        }
    }
}
&lt;/pre&gt;

That redirects the current url to ssl url. It&#039;s called in the controller you want to have only ssl request like payment pages. For generating anchor if you have the base_url dynamically generated like stated above, anchors are generated with https if the pages are in https. So don&#039;t need the secure anchor. Hope this helps!</description>
		<content:encoded><![CDATA[<p>I have base url dynamically defined  in my apps as</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTPS'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTPS'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;on&quot;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;https&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;http&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;://&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_HOST'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'base_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SCRIPT_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SCRIPT_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>AND for SSL redirect I use a utility helper</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ssl_redirect'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">function</span> ssl_redirect<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SERVER_PORT&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">443</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            redirect<span style="color: #009900;">&#40;</span><span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;https://&quot;</span> <span style="color: #339933;">,</span> current_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;refresh&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>That redirects the current url to ssl url. It&#8217;s called in the controller you want to have only ssl request like payment pages. For generating anchor if you have the base_url dynamically generated like stated above, anchors are generated with https if the pages are in https. So don&#8217;t need the secure anchor. Hope this helps!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

