1
<IfModule mod_rewrite.c>
   RewriteEngine On

   # Force SSL
   RewriteCond %{HTTPS} !=on
   RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
   # Remove public folder form URL
   RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

This is my .htaccess in the root directory. I have another .htaccess in public directory.

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
</IfModule>

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

https is working perfectly fine. What I want to achieve is that, if I type www.something.com or something.com or http://something.com it should go to https directly.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Bikram Nath
  • 483
  • 6
  • 15
  • 2
    Does this answer your question? [How to redirect all HTTP requests to HTTPS](https://stackoverflow.com/questions/4083221/how-to-redirect-all-http-requests-to-https) – glinda93 Mar 07 '20 at 17:09
  • If I type www.somethinig.com, it goes to https, but if I type something.com, it still loads in http protocol. what am I doing wrong? – Bikram Nath Mar 08 '20 at 15:48

1 Answers1

0

You can put this in your web.php

\URL::forceScheme('https');
Ruben Danielyan
  • 728
  • 4
  • 19