将HTTP重定向到HTTPS [英] Redirect HTTP to HTTPS

查看:116
本文介绍了将HTTP重定向到HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前使用此代码将HTTP重定向到HTTPS:

I currently use this code to redirect HTTP to HTTPS:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

它正在工作, http://website.com 被重定向到 https://website.com/about 或<一个href ="https://website.com/contact" rel ="nofollow noreferrer"> https://website.com/contact 我被重定向到

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

仅当我已经在网站上时,我才可以访问/pages. 如何解决这个问题? 我尝试了几个.htaccess脚本,但没有一个起作用.

I can only visit /pages when I'm already on the website. How to fix this? I tried several .htaccess scripts but none worked.

尝试单击 http://ndvibes.com/about ,您将重定向到index.php如果您尚未登录该网站. 怎么修?谢谢!

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!

推荐答案

这应该会更好.

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://website.com/$1 [R=301,L]

这篇关于将HTTP重定向到HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆