[英].htaccess redirect folder and subfolder except for some subfolders
i have a problem with my .htaccess I want to redirect any page and subfolder in the folder /w/ to the main page of my website, so i want to do something like this: 我的.htaccess有问题我想将文件夹/ w /中的任何页面和子文件夹重定向到我网站的主页面,所以我想做这样的事情:
www.mysite.com/w/ - redirect -> www.mysite.com
www.mysite.com/w/subfolder/ - redirect -> www.mysite.com
But, i want to NOT redirect some subfolder like: 但是,我想不重定向一些子文件夹,如:
www.mysite.com/w/subfolder1 --> not redirect
www.mysite.com/w/subfolder2 --> not redirect
My htaccess is: 我的htaccess是:
RedirectMatch 301 /w/(?!subfolder1) /$1
But it doesn't work, i tried with: 但它没有用,我尝试过:
RedirectMatch 301 /w/(?!^subfolder1) /$1
and 和
RedirectMatch 301 /w/(?!subfolder1$) /$1
But nothing was right! 但没有什么是对的!
Please help me :( 请帮我 :(
Try : 试试:
RedirectMatch 301 ^/w/((?!subfolder1|subfolder2).*) /$1
You can exclude more folders from the directive, just seperate them using a bar | 您可以从指令中排除更多文件夹,只需使用条形|将它们分开
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.