lundi 16 avril 2018

.htaccess redirecting to `www.www.mydomain.com`

I'm building a site using Laravel5 and I'm having an issue with my .htaccess file redirecting to https://www.www.example.com. I was trying to force redirect from http to https and now I'm getting duplicate www. in the URL.

Accessing the site via https://example.com (without www) works fine however.

Here is my .htaccess file contents:

<IfModule mod_rewrite.c>
    DirectoryIndex public/index.php public/index.html

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

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{HTTP_HOST} ^(www\.)?example\.com
    RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

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

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

Can anyone provide a suggestion on what needs to change to force a redirect to https while allowing the following URLs to access the site:

  • www.example.com
  • https://example.com
  • https://www.example.com


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire