[英]Mod rewrite, redirect all to https except specific URI and redirect that URI from https to http
So I've been hitting a wall have have tried many different options, and configurations. 因此,我碰到了一堵墙,尝试了许多不同的选项和配置。 I'm trying to redirect my site to https with the exception of one specific URI which I want to be redirected from https to http and then remain http.
我正在尝试将我的网站重定向到https,但我想将一个特定的URI从https重定向到http,然后保持http。 I would greatly appreciate any help.
我将不胜感激任何帮助。 This is being done from the virtualhost configuration.
这是通过virtualhost配置完成的。 Below are the settings I have tried in pairs with ssl.conf and mysite.conf.
以下是我与ssl.conf和mysite.conf配对使用的设置。 However I keep either getting a redirect loop or a page that doesn't load.
但是,我一直收到重定向循环或无法加载的页面。
mysite.conf mysite.conf
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !/example
RewriteRule ^(.*)$ https://my.site.com$1 [R,L]
or 要么
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} ^(/|page1|page2)
RewriteRule ^(.*)$ https://my.site.com$1 [R,L]
or 要么
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !=/example
RewriteRule ^(.*)$ https://my.site.com$1 [R,L]
or 要么
RewriteCond %{REQUEST_URI} =/example
RewriteRule ^(.*)$ http://my.site.com$1 [R,L]
Plus one of the above. 再加上以上之一。
Then in ssl.conf 然后在ssl.conf中
RewriteEngine on
RewriteCond %{REQUEST_URI} =/example
RewriteRule ^(.*)$ http://my.site.com$1 [R,L]
This should do it for you. 这应该为您做。 Place the most specific rule (that for
/example
) first. 首先放置最具体的规则(对于
/example
)。
RewriteEngine on
RewriteCond %{HTTPS} =on
RewriteRule ^/?example$ http://my.site.com/example [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/?example$
RewriteRule ^/?(.*)$ https://my.site.com/$1 [R=301,L]
This should work in either server (.conf) or directory (.htaccess) context. 这应该可以在服务器(.conf)或目录(.htaccess)上下文中使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.