通过的.htaccess重定向HTTPS到HTTP [英] Redirecting HTTPS to HTTP via .htaccess

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

问题描述

我用一个词preSS其默认的.htaccess,我需要重定向开始以https所有URL://到http://。我的服务器使用相同的文件夹,HTTP和HTTPS协议... 这是我目前的.htaccess:

I'm using a WordPress with its default .htaccess and I need to redirect all urls starting with https:// to http://. My server is using the same folder for http and https protocols... this is my current .htaccess:

# BEGIN WordPress <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase 
RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L] </IfModule> 
# END WordPress

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]


它工作正常的 https://www.domain.com/ (重定向到的 http://www.domain.com/ 的),但它不与 https://www.domain.com/subpages/ (它也重定向到的 http://www.domain.com/ )。


It works fine for https://www.domain.com/ (redirects to http://www.domain.com/) but it doesn't work with https://www.domain.com/subpages/ (it also redirects to http://www.domain.com/).

你看到的任何问题,在.htaccess中吗?

Do you see any problem in .htaccess please?

感谢您

推荐答案

更​​改规则的顺序:

Options +FollowSymlinks

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{SERVER_PORT} ^443$
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]

    # BEGIN WordPress
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress
</IfModule>

否则的话preSS规则将捕获所有请求的URL路径不为空(即不只是 / )。

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

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