apache 在本地主机上禁用 https

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1795665/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:26:05  来源:igfitidea点击:

Disable https on localhost

apachehttps

提问by Amir E. Habib

I need to automatically redirect any https:// to http:// on my localhost environment. I tried to use a .htaccess file which I placed on my htdocs/ with the following code:

我需要在我的本地主机环境中自动将任何 https:// 重定向到 http://。我尝试使用一个 .htaccess 文件,该文件放在我的 htdocs/ 上,代码如下:

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

For some reason this is not working. Any advice?

出于某种原因,这不起作用。有什么建议吗?

采纳答案by leepowers

The problem with the rewrite rule is that it will never be reached if apache is not configured properly for SSL. The browser is trying to connect to http://localhost:443and unless apache or some other service is configured on that port you'll get a timeout.

重写规则的问题在于,如果 apache 没有为 SSL 正确配置,它将永远不会达到。浏览器正在尝试连接到http://localhost:443,除非在该端口上配置了 apache 或其他一些服务,否则您将获得超时。

The best solution would be to create a self-signed certificate for apache running on localhost and create a rule in your web browser to trust the certificate:

最好的解决方案是为在 localhost 上运行的 apache 创建一个自签名证书,并在您的 Web 浏览器中创建一个规则来信任该证书:

Create a self-signed certificate for apache:

为 apache 创建一个自签名证书:

http://www.perturb.org/display/entry/754/

http://www.perturb.org/display/entry/754/