简体   繁体   English

如何从 https 重定向到 http

[英]how redirect from https to http

I need to redirect from https to http this is my .haccess file :我需要从 https 重定向到 http 这是我的 .haccess 文件:

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

The code you posted is an HTTP to HTTPS redirect, so you just need to reverse the logic:您发布的代码是 HTTP 到 HTTPS 的重定向,因此您只需要反转逻辑:

RewriteCond %{HTTPS} =on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

(I've also simplified the regex ^(.*)$ to ^ .) (我还将正则表达式^(.*)$简化为^ 。)

You do, however, still need to have a valid SSL cert installed on your server for the redirect to be effective, as otherwise the user-agent won't even reach your server to run your code.但是,您仍然需要在服务器上安装有效的 SSL 证书才能使重定向生效,否则用户代理甚至无法到达您的服务器来运行您的代码。

And... redirecting from HTTPS to HTTP in the first place doesn't make a whole lot of sense in 2019.而且……首先从 HTTPS 重定向到 HTTP 在 2019 年没有多大意义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM