I just installed a SSL certificate on my site, but now I'm facing a problem when I try to force all users to go through secure SSL (HTTPS) instead of HTTP. I found that the way to to it is using the code below on .htaccess
#Force SSL on entire site
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
So far, it's not working, I get a redirect loop error.
It's redirecting to the SSL URL, but not working.. without the .htaccess rule it works when i type manually https://example.com
I have no idea if this will work for you but I do the same thing for my site and this is the code in my .htaccess
file. I am sure I got it from somewhere here on Stack Overflow.
<IFModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IFModule>
Try this:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Should work fine...
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.