htaccess的重定向HTTPS URL到http [英] .htaccess redirect https url to http

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

问题描述

我有与使用https一些地区的网站,但我有问题,改变了几HTTPS URL中到http的。这正是我需要的:

I have a website with some areas that use https, however I'm having problems changing a few https urls to http ones. This is what I need:

更改此URL网址

https://www.domain.com/somefile.php?PossibleGetParameters

这样:

http://www.domain.com/somefile.php?PossibleGetParameters

这是我对我的.htaccess:

This is what I have on my .htaccess:

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^(/somefile.php)
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

有了这个条件的所有HTTPS URL中都变成了HTTP,而我只想要这个特殊的改变。有什么办法解决这一问题?

With this condition all https urls are turned into http, and I only want this particular one to change. Is there any way to fix this?

推荐答案

当然...只是删除感叹号 从第二个条件 - 在该位置它否定该规则。

Sure ... just remove the exclamation mark ! from second condition -- in that position it negates the rule.

最终规则将是:

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/somefile.php
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

我已经简化了规则的一点点(因为你需要它的单个URL只)。

I've simplified the rule a tiny bit (as you need it for a single URL only).

该规则可能无法马上为现代的浏览器做缓存301重定向..所以浏览器可能会记住你的previous尝试。因此,清除浏览器缓存和测试规则之前重新启动(或尝试使用其他浏览器)。

This rule may not work straight away as modern browsers do cache 301 redirects .. so browser may remember your previous attempts. Therefore clear browser caches and restart it before testing the rule (or try another browser).

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

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