Reroute http to https

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 ?

is this it?
https://www.namecheap.com/support/knowledgebase/article.aspx/9410/29/how-to-set-up-rules-and-redirects-in-htaccess

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>

php – BEGIN cPanel-generated handler, do not edit

This domain inherits the “PHP” package.

php – END cPanel-generated handler, do not edit

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.

RewriteEngine on RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.midominio.com/$1 [R,L] RewriteRule ^$ webroot/ [L] RewriteRule (.*) webroot/$1 [L]