问题
I currently use this code to redirect HTTP to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
It's working, http://website.com gets redirected to https://website.com, however when I'm not on the website and try to go https://website.com/about or https://website.com/contact I get redirected to https://website.com/index.php
I can only visit /pages when I'm already on the website. How to fix this? I tried several .htaccess scripts but none worked.
Try to click http://ndvibes.com/about you'll get redirected to index.php if you're not already on the website. How to fix? Thanks!
回答1:
This should work better.
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://website.com/$1 [R=301,L]
来源:https://stackoverflow.com/questions/44483830/redirect-http-to-https