将域重定向到https并将特定文件夹重定向到no-https

时间:2019-05-13 06:25:24

标签: regex apache .htaccess mod-rewrite

我正在为重定向2个或更多文件夹寻找良好的正则表达式

我有很多网址,例如:

  

https://www.my-domaine.com/studiant/test-num/42

     

https://www.my-domaine.com/studiant/helper-helper

     

https://www.my-domaine.com/toto-titi-tahah/blalbla

但是我想将两个“最终”网址重定向到无https

https://www.my-domaine.com/studiant/helper-helper/theme/math/ressrouce/20  

https://www.my-domaine.com/studiant/test-num/42

我已经尝试了几种方法,正则表达式,但是100%都无效。

RewriteCond %{THE_REQUEST} \s/+studiant/helper-helper/theme/(.*)/ressource/(.*)[/?\s] [NC,OR]
RewriteCond %{THE_REQUEST} /studiant/test-num/[0-9]+ [NC]

RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule ^((?!test-num.*|ressource).*)$ https://%{HTTP_HOST}%REQUEST_URI} [NE,L,R]
RewriteCond %{HTTPS} on
RewriteRule ^test-num.*|ressource*)$ http://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]

我尝试了这个: How to redirect site to https and http using htaccess for specific file and folder

0 个答案:

没有答案