Reputation: 523
I have a .htaccess that's supposed to force connection using SSL. It works well on localhost, when I take it online I have all manner of errors. Here is my code.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z]*)/?$ goto.php?page=$1
ErrorDocument 404 PageNotFound
IndexIgnore *
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
Where am I missing it please, thank you.
Upvotes: 0
Views: 343
Reputation: 2402
The problem is here:
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
The ^(.*)$
matches everything so will keep matching even after it has redirected the user to https, thus the infinite loop.
So you need to make this rule only match when it is required, the folloing RewriteCond
should cause the rule to only match whilst https is off, which should stop the infinite loop:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
Upvotes: 1