301将HTTPS重定向到单个页面的HTTP [英] 301 redirect HTTPS to HTTP for a single page

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

问题描述

我目前已将SSL证书应用于我的网站,并且所有网址都正确地重定向到https。我需要其中一个URL是HTTP。我在.htaccess中有以下代码,将所有页面重定向到HTTPS。

I currently have a SSL certificate applied to my site and ALL URLs redirect to https correctly. I need one of the URLS to be HTTP. I have the following code in my .htaccess that redirects all pages to HTTPS.

我希望下面的URL是HTTP而不是HTTPS。

I would like the following URL below to be HTTP and NOT HTTPS.

http://www.example.com/blog_rss.php

RewriteEngine on
RewriteBase /
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

预先感谢您的协助!

推荐答案

你可以用你的htaccess替换你当前的代码

You can replace your current code by this one in your htaccess

RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/blog_rss\.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,QSA]

RewriteCond %{HTTPS} on
RewriteRule ^(blog_rss\.php)$ http://%{HTTP_HOST}/$1 [R=301,L,QSA]






编辑:看起来像某些人无法识别%{HTTPS} 服务器,导致无限循环。


looks like %{HTTPS} is not recognized on some servers, which is causing an infinite loop.

尝试使用%{SERVER_PORT} (如果默认http端口仍为80且ssl端口为443)

Try with %{SERVER_PORT} (if default http port is still 80 and ssl port is 443)

RewriteEngine On
RewriteBase /

RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/blog_rss\.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,QSA]

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

您也可以尝试初始语法

RewriteEngine On
RewriteBase /

RewriteCond %{ENV:HTTPS} !on [NC]
RewriteCond %{REQUEST_URI} !^/blog_rss\.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,QSA]

RewriteCond %{ENV:HTTPS} on [NC]
RewriteRule ^(blog_rss\.php)$ http://%{HTTP_HOST}/$1 [R=301,L,QSA]

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

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