Hi Reader's,
Welcome to FindNerd, today we are going to discuss how to enable SSL in CakePhp.
Basically, SSL is a very important feature in a CakePHP web application. We can enable ssl https in our CakePHP application on the server. We can integrate tighter security in our application using security component.
We can enable SSL on live server by following these steps:-
1. We have to add or change our BASE_URL according our web application.
So, in our core.php we will add/change the BASE_URL definition to https like below code:
<?php
define('BASE_URL','https://'.$_SERVER['HTTP_HOST']);
Configure::write('BASE_URL','https://'.$_SERVER['HTTP_HOST']);
?>
2. We have to modify our website "/app/webroot/.htaccess" and "/app/.htaccess" to:
we can see below code for better understanding:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
I hope this blog will help you to enable SSL in your CakePHP application.
0 Comment(s)