DEV Community

Hòa Nguyễn Coder
Hòa Nguyễn Coder

Posted on

Laravel Redirect HTTP to HTTPS via .htaccess

Today, i share with you, redirect http to Https in laravel
You create file .htaccess in root laravel

RewriteEngine On
RewriteRule ^(.*)$ public/ [L]
Enter fullscreen mode Exit fullscreen mode

Way code above it redirect to http, if you want http to https, you can using following code above

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

Post:Laravel Redirect HTTP to HTTPS via .htaccess

Top comments (1)

Collapse
 
gundogduyakici profile image
Gündoğdu Yakıcı

Thank you for shared