开发者

.htaccess redirect https url to 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:

change this url url

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

to this:

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

This is what I have on my .htaccess:

RewriteC开发者_如何转开发ond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^(/somefile.php)
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

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.

The final rule will be:

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

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

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜