HTTPS对HTTP重定向使用htaccess的 [英] Https to http redirect using htaccess

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

问题描述

我想重定向 https://www.example.com 到的 http://www.example.com 。我尝试以下code在.htaccess文件

I'm trying to redirect https://www.example.com to http://www.example.com. I tried the following code in the .htaccess file

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

这code成功重定向 https://example.com 到的 http://www.example.com 。在然而,当我键入 https://www.example.com 然后它给了我一个找不到网页在浏览器中的错误。

This code successfully redirects https://example.com to http://www.example.com. However when I type in https://www.example.com then it gives me a "web page not available" error in the browser.

我也曾尝试以下2 codeS没有成功

I have also tried the following 2 codes without success

尝试1

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*):NOSSL$ http://www.example.com/$1 [R=301,L]

尝试2

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

两个以上尝试失败。有什么建议?

Both above attempts failed. Any suggestions?

推荐答案

尝试二是接近完美。只要修改悦目:

Attempt 2 was close to perfect. Just modify it sightly:

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

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

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