Hi, I have my website on https which was on http. How do I redirect/reroute users to https ? I was quite clear where I need to do this in cakephp3. I see some methods using cakephp2 but this is using older framework.
Thanks
Andrew
Hi, I have my website on https which was on http. How do I redirect/reroute users to https ? I was quite clear where I need to do this in cakephp3. I see some methods using cakephp2 but this is using older framework.
Thanks
Andrew
You should try the .htaccess file
isnt there a cakephp3 solution?
Using .htaccess is the optimal solution. You can do it via CakePHP but that is less than the best.
You can do it via the Security-Component.
https://book.cakephp.org/3.0/en/controllers/components/security.html#restrict-actions-to-ssl
If your action is called over http instead of https, the request is “blackholed”.
Example:
In your AppController.php
public function initialize()
{
...
$this->loadComponent('Security', ['blackHoleCallback' => 'forceSSL']);
}
public function beforeFilter(Event $event)
{
$this->Security->requireSecure();
}
public function forceSSL()
{
return $this->redirect('https:/my-domain.com' . $this->request->getRequestTarget());
}
With .htaccess you can use the following
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.fomedeofertas.com.br/$1 [R,L] </IfModule>
with .htaccess where is this when using cpanel ?
This code currently exists in htaccess so what do i do now as tbhis didnt work. It doesnt redirect http to https and i edited out the actual domain?
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://crm.xxxxx.au/$1 [R,L]
</IfModule>
Este codigo me sirvio en el .htaccess ya que redirecciona todas las rutas del proyecto.
en el lugar de www.midominio.com va tu domino.