Seeker1337
6 months ago
2437
5
Laravel

Laravel 6+ Force redirections from http to https

Posted 6 months ago by Seeker1337

Hey there, I've recently uploaded my website to a VPS ( ubuntu 18.04 with webmin/virtualmin/lamp ) and added a Comodo SSL. However, when I try to access my website through http:// connection I get redirected to a blank page that's currently displaying the following text " Index of / " and below it " Name, Last modified, Size, Description". It's all blank it doesn't show any data.

The bad part is when I type my website's name in the tab and hit enter I get redirected to this http connection. My website's HTTPS connections are all set and running properly.

EDIT: It's also weird that when I get redirected to that blank page and hit Enter in the URL tab section I get redirected through the HTTPS connection. Its like if I type it twice I then get a proper connection. Here is my .htaccess file:


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

        RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteEngine On 
    RewriteCond %{HTTP_HOST} ^my-domain\.com [NC]
    RewriteCond %{SERVER_PORT} 443 
    RewriteRule ^(.*)$ https://my-domain.com/ [R=301,L]

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

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

Here is my .env file:


APP_NAME=not important
APP_ENV=production
APP_KEY=not important
APP_DEBUG=false
APP_URL=https://my-domain.com

LOG_CHANNEL=daily


Please sign in or create an account to participate in this conversation.