在本地主机上禁用 https
我需要在本地主机环境中自动将任何 https:// 重定向到 http:// 。 我尝试使用一个 .htaccess 文件,该文件放在我的 htdocs/ 上,代码如下:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
由于某种原因,这不起作用。有什么建议吗?
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:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
For some reason this is not working. Any advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
重写规则的问题是,如果 apache 没有正确配置 SSL,则永远无法达到重写规则。浏览器正在尝试连接到 http://localhost:443 并且除非在该端口上配置了 apache 或其他一些服务你会得到一个超时。
最好的解决方案是为在本地主机上运行的 apache 创建一个自签名证书,并在 Web 浏览器中创建一个规则来信任该证书:
apache 创建一个自签名证书:
为 perturb.org/display/entry/754/" rel="nofollow noreferrer">http://www.perturb.org/display/entry/754/
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:443 and unless apache or some other service is configured on that port you'll get a timeout.
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:
Create a self-signed certificate for apache:
http://www.perturb.org/display/entry/754/
单击 Xampp 配置并将此行添加到 httpd.conf
Click on Xampp config and add this line to httpd.conf