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:
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:
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 |
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.