[英]How to force http on specific folder in https site
I have site with https 我的网站带有https
But I need specific folder should be http. 但是我需要的特定文件夹应该是http。
How can we achieve it ? 我们如何实现呢?
eg my site is 例如我的网站是
https://www.mywebsite.com
I want folder1/subfolder1
should be forced to http://
我想将
folder1/subfolder1
强制设置为http://
eg http://www.mywebsite.com/folder1/subfolder1
例如
http://www.mywebsite.com/folder1/subfolder1
I searched on net...but maximum search show how to force http
to https
我在网上搜索...但是最大搜索量显示了如何将
http
强制为https
I tried .htaccess
as follows : 我尝试
.htaccess
如下:
try 1.
RewriteRule ^(/folder1/subfolder1)($|/) - [L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
try 2.
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/folder1/subfolder1
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
But it didn't work.. 但这没用..
You can use these rules in your site root .htaccess: 您可以在网站根目录.htaccess中使用以下规则:
RewriteEngine On
# force https on everything except /folder1/subfolder1
RewriteCond %{THE_REQUEST} !\s/+folder1/subfolder1[/?\s] [NC]
RewriteCond %{HTTPS} !on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]
# force http on /folder1/subfolder1
RewriteCond %{THE_REQUEST} \s/+folder1/subfolder1[/?\s] [NC]
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
Make sure to clear your browser cache or use a new browser for testing. 确保清除浏览器缓存或使用新的浏览器进行测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.