如何使用htaccess强制使用HTTP- NOT https [英] How to force http- NOT https using htaccess

查看:183
本文介绍了如何使用htaccess强制使用HTTP- NOT https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要强制使用https的整个域有一个目录,即 / docs。在/ docs文件夹中,我具有以下htaccess文件:

I have ONE directory for my entire domain that I want to force https, which is "/docs". In the /docs folder, I have the following htaccess file:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

这迫使https进入/ docs目录中的所有内容,这是我希望它执行的操作。我遇到的问题是试图将我网站的所有其他区域的REMOVE https强制回http。在网站的根文件夹(正在运行wordpress)中,我具有以下htaccess文件:

This is forcing https to everything in the /docs directory, which is what I want it to do. The problem I am having is trying to force REMOVE https back to http for all other areas of my site. In the root folder of the site (which is running wordpress), I have the following htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/docs/?.*$
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]

很遗憾,这不起作用。我仍然可以通过https访问我网站的其他区域。

Unfortunately, this is not working. I can still access other areas of my site over https.

需要做些什么才能使其正常工作?

What do I need to change to get this to work correctly?

推荐答案

为什么需要还原为http?如果您拥有适当的SSL证书,则还可以确保访问安全。除非您担心系统上的负载。

Why do you need to revert back to http? If you have the proper SSL certificates you might as well keep your access secure. Unless you are concerned about the load on your system.

我知道这不是在回答问题,但我想强调的是,这个问题是在询问如何做 不良做法 ,首先不应该这样做。

I know this is not answering the question, but I want to emphasize that the question is asking on how to do a bad practice, which shouldn't be done in the first place.

这篇关于如何使用htaccess强制使用HTTP- NOT https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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