0

I am beginner in Laravel. I make my project in Laravel 5.8. I have website in domain: https://myname.com

I need .htacess with options: - redirect from http to https, - redirect from www.myname.com to myname.com

How can I make this?

trops
  • 3
  • 3
  • *"I need .htacess with options: - redirect from http to https, - redirect from www.myname.com to myname.com"* ... better to do that at the `` level in *httpd-vhosts.conf* - I assume you've got access to that if you're attempting to setup HTTPS. – CD001 Aug 05 '19 at 10:52

1 Answers1

1

You have to have SSL certificate to use https. Here is my .htaccess file which works for me to redirect from http to https.

<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]
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://www.sitename.com/$1 [R,L]
</IfModule>

<IfModule mod_headers.c>
    <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
        Header set Access-Control-Allow-Origin "*"
    </FilesMatch>
</IfModule>
zahid hasan emon
  • 6,023
  • 3
  • 16
  • 28