Welcome Guest, Not a member yet? Register   Sign In
codeigniter redirect url to point to https
#1

[eluser]Unknown[/eluser]
I have an app that needs to be behind an https. I have the ssl so that's all set.. If the person specifies https://www... then everything is fine, but when the person doesn't specify https://www.. then i need to redirect them to the https. I'd like to do this with the .htaccess foldder, but every time i set it up the index.php page breaks and the browser attempts to serve up a .phtml.part file for me to download...

help!


this is the rewrite:
Code:
RewriteEngine on

RewriteCond %{SERVER_PORT} !443
RewriteRule ^(.*)$ https://localhost/location/$1 [R=301,L]
#2

[eluser]Jamie Rumbelow[/eluser]
You can use a simple helper method which you can call on any of your controller links. Credit to @nevercraft on the forums for this:

Code:
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());
        }
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB