How do I force HTTPS for certain parts of a site, e.g. a login page or register page, and use HTTP for the rest of the site?
My favorite convert to https forcing method is to put this as the first thing in your php script. It works in Joomla, and may very well work in CakePHP.
if( $_SERVER['SERVER_PORT'] == 80) {
header('Location:https://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/'.basename($_SERVER['PHP_SELF']));
die();
}
This snippet will force https on whatever page you are viewing. If you want to isolate certian pages, just put some conditions based on the information in the "$_SERVER['PHP_SELF']" variable.
Otherwise, modify the .htaccess file, assuming your host allows you access to this:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} somefolder
RewriteRule ^(.*)$ https://www.domain.com/somefolder/$1 [R,L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With