Skip links

Laravel Redirect HTTP to HTTPS via .htaccess

Simply create an .htaccess file in your root folder and add the following code to it. This will do 2 things.

  1. Redirect all http requests to https
  2. Take public folder as root for the laravel installation.
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTPS} !=on    
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Hope this helps!

Leave a comment