使用 htaccess 将 Https 重定向到 http [英] Https to http redirect using htaccess
问题描述
我正在尝试将 https://www.example.com 重定向到 http://www.example.com.我在 .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]
此代码成功将 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个代码没有成功
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?
推荐答案
尝试 2 接近完美.稍微修改一下:
Attempt 2 was close to perfect. Just modify it slightly:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
这篇关于使用 htaccess 将 Https 重定向到 http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!