简体   繁体   中英

htaccess RewriteRule for folder

I have a bunch of rewrite rules I would like to implement. I would like to redirect anything that has /blog/tag/... to my root url.

For example, all of these:

blog/tag/button-sets/
blog/tag/icons/
blog/tag/order-now/
blog/tag/body-attributes/

Would simply route to: www.url.com

I can do it on a case-by-case basis like below, but would like to redirect a bunch with 1 rule. Any help would be greatly appreciated

RewriteCond %{HTTP_HOST} ^url\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.url\.com$
RewriteRule ^blog\/tag\/button\-sets\/?(.*)$ "http\:\/\/www\.url\.com\/$1" [R=301,L]

Why dont you just remove the button-sets part of your rule like so

RewriteRule ^blog\/tag\/?(.*)$ "http\:\/\/www\.url\.com\/" [R=301,L]

Havent tested it but should be OK?

取而代之的是使其捕获第二个之后的所有内容,然后捕获到Blog / tag /(ANYTHING)/(CAPTURE)之后的所有内容,这些内容将重定向到www.url.com/CAPTURE

RewriteRule ^blog\/tag\/.*\/?(.*)$ "http\:\/\/www\.url\.com\/$1" [R=301,L]

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM