简体   繁体   中英

Laravel: Redirect to https://www.*** does not work in Firefox?

I added to the .htaccess file this code https://stackoverflow.com/a/13997498/2311074 to redirect my website always to https://www.********** . This works in Chrome, but it is not working in Firefox.

If I enter

https://example.com

then its not redirecting anywhere.

in Firefox. In Chrome they are correctly redirected to https://www.example.com .

I aready deleted the cache and tried to call the website from other PC's but its still not working. This is my htaccess FIle from Laravel:

<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]

    RewriteCond %{HTTPS} off
    # First rewrite to HTTPS:
    # Don't put www. here. If it is already there it will be included, if not
    # the subsequent rule will catch it.
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    # Now, rewrite any request to the wrong domain to use www.
    # [NC] is a case-insensitive match
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

</IfModule>

What am I doing wrong?

The problem was that I only had a SSL certificate for the domain www.example.org but not a SSL certificate for the domain example.org . Thus the url https://example.org is invalid, was not loaded and could not be redirected with the .htaccess file.

请参阅下面的评论以获取问题的答案。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM