Problem:

When Want redirect root domain or subdomain Http to https in Laravel project The reason behind Http to https redirection is the .htaccess manage on the root of your domain or subdomain.

  1. if you hit your domain/public you will be accessible of your project
  2. if you want to directly show the project on the domain you manage .htaccess with the following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Solution:

Change .htaccess code on your root domain/subdomain with the following codes

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

LEAVE A REPLY

Please enter your comment!
Please enter your name here