Noah Goodrich
Noah Goodrich

Reputation: 315

SSL with Codeigniter htaccess

OK so i'm having a bit of trouble with .htaccess.

I'm using Codeigniter and have just installed a SSL certificate. It's working great except I don't get the blue bar in Firefox, it says 'Your connection to this site is only partially encrypted'

Here's my .htaccess file:

RewriteEngine on
Options +FollowSymLinks
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (signin)
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !(signin)
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

I only want to force SSL on some pages, to start with the signin page (mydomain.com/signin). It seems to remove the index.php/ in the URL fine and it does seem to be forcing the SSL for that page but there's no blue bar :(

I also changed my base_url to the following in the config file to allow http and https:

$config['base_url'] = $config['base_url'] = "http".((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "")."://".$_SERVER['HTTP_HOST'].str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);  

Any help is most appreciated :)

Upvotes: 1

Views: 1548

Answers (1)

Stelian Matei
Stelian Matei

Reputation: 11623

I think the error is caused by having elements in your page which are downloaded using HTTP instead of HTTPS.

You need to make sure that you either reference all the elements in the page with relative URLs or absolute URLs with the proper protocol (HTTPS instead of HTTP).

Upvotes: 1

Related Questions