简体   繁体   中英

How do I create an htaccess redirect for multiple directories

I have to create a htaccess redirect for multiple image directories within a path to a root level image directory. The paths all have a variable within them though, in my case a directory named after a city/state...

We have a number of mini sites within our corp site, each mini site has its own image directory: .../images/u/whatever.jpg

Examples:

root/store/local/birmingham-al/images/u/

root/store/local/mongomery-al/images/u/

root/store/local/nashville-tn/images/u/

I need a quick redirect that will tell the server to use the new shared image dir, instead of having images served from each of the /images/u/

All server requests should redirect image requests to:

root/imagecdn

How can I do it so I only effect images in those /images/u/ directories?

I suck at regex but I'm certain it can be done. We need this as a quick fix instead of manually changing 1000+ paths.

Does this regexp satisfy your needs?

/^.*/images/u(.*)$/gm

And the replacement string is root/imagecdn$1 .

Example

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