Codeigniter, force ssl on a specific page
I am having a hard time trying to force https (ssl) to a specific page based on codeiginiter. I tried many ways but none worked. The only way I've worked with was to change the site link $ config ['base_url'] to start with https instead of http . As a result, all links were set to ssl (whole site), which doesn't make sense because I don't need to use SSL everywhere. I used some php code on the login page but it caused some problems so I gave up on it.
I want to know if this is a good method how to do it, any idea?
Thank,
source to share
You need to add a condition on .htaccess
to use the SSL port only for the selected URLs.
Here is an example how to do
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} controller/function
RewriteRule ^(.*)$ https://www.yourdomain.com/controller/function[R=301,L]
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} controller/function
RewriteRule ^(.*)$ https://www.yourdomain.com/controller/function[R=301,L]
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
PS: Yours base_url
must be set to "/"
in your config file. For more information check http://codeigniter.com/wiki/SSL_Handling
source to share