htaccess HTTPS仅无重定向 [英] htaccess HTTPS only no redirect

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

问题描述

我想完全阻止端口80(HTTP),并且只允许HTTPS请求。我发现了许多有关如何从HTTP重定向到HTTPS的示例,但我希望显示一个错误。我无法在配置文件中阻止端口80,因为托管服务提供商不允许我修改这些文件。如果可能,如何使用htaccess获得相同的结果。

I want to block port 80 (HTTP) completely and only allow HTTPS requests. I have found many examples of how to redirect from HTTP to HTTPS but I would prefer to display an error instead. I cannot block port 80 in my config file as my hosting provider does not allow me to modify these files. If possible, how can I achieve the same results with htaccess.

在阅读此文章

引用


除了完全放弃HTTP Basic,还有一个简单的解决方法。关闭API主机上的端口80。这样可以防止连接死线,从而防止任何凭据以明文方式发送

Aside from abandoning HTTP Basic altogether there is an easy fix. close port 80 on your API host. This stops a connection being made dead in its tracks, preventing any credentials being sent in the clear


推荐答案

尝试:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !/error\.php
RewriteRule ^ http://%{HTTP_HOST}/error.php [L,R]

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ - [L,F]

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

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