Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8230973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:19:06+00:00 2026-06-07T17:19:06+00:00

I am trying to adopt a ssl routing solution to my shopping cart app

  • 0

I am trying to adopt a ssl routing solution to my shopping cart app so that certain pages are “forced” to be https:// pages and visa-verse. Through research I have come across many solutions which involve the use of code either in a helper, a hook or in a controller. I have tried a few of these solutions and in each, I get a redirect error when switching to an https:// page.

Here is the last version I have tried (found here: http://nigel.mcbryde.com.au/2009/03/working-with-ssl-in-codeigniter):

Create a file in application/helper called ssl_helper.php

if (!function_exists('force_ssl'))
{
    function force_ssl()
    {
        $CI =& get_instance();
        $CI->config->config['base_url'] =
                 str_replace('http://', 'https://',
                 $CI->config->config['base_url']);
        if ($_SERVER['SERVER_PORT'] != 443)
        {
            redirect($CI->uri->uri_string());
        }
    }
}

function remove_ssl()
{
    $CI =& get_instance();
    $CI->config->config['base_url'] =
                  str_replace('https://', 'http://',
                  $CI->config->config['base_url']);
    if ($_SERVER['SERVER_PORT'] != 80)
    {
        redirect($CI->uri->uri_string());
    }
}

Load the helper, then in the constructor for any controller that requires ssl, simply insert:

force_ssl();

In every controller that you don’t want to have ssl put:

if (function_exists('force_ssl')) remove_ssl();

As stated above, when using this, I get stuck in a redirect loop and get an error (though the url has the https:// as it should). Could my problem be in my .htaccess file? Here is my .htaccess file:

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /store
   RewriteCond $1 !^(index.php\.php|resources|robots\.txt)
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>

I’ve been at this for over a week now! Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:19:08+00:00Added an answer on June 7, 2026 at 5:19 pm

    I answered a similar question here: https://stackoverflow.com/questions/1500527/how-to-use-ssl-with-codeigniter/1500558#1500558

    But, in a nutshell:

    <IfModule mod_rewrite.c>
       RewriteEngine On
       RedirectPermanent /sslfolder https://www.yoursite.com/sslfolder
    </IfModule>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to adopt bitmap resizing tutorial - the only difference is that I
I'm trying to adopt devise to my app Here is the content of Routes.rb
I am trying to adopt that example into my existing Spring application. However I
I'm trying to adopt some best practices to keep my python code efficient. I've
I'm trying to adapt an xla add-in that I wrote for Excel 2007 to
I'm trying to adapt a VBscript that runs the QWINSTA command against a text
I have a custom accordion script that I'm trying to adapt for another site.
I'm trying to adopt Fluent NHibernate with my project, currently I can get data
I am Fortran beginner and I am trying to adopt some ifort code for
I have been trying to get our software department to adopt some kind development

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.