Redirect HTTP to HTTPS

拈花ヽ惹草 提交于 2020-01-07 05:29:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!