Welcome to WebmasterWorld Guest from 23.20.101.42

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Redirect Images Directory With htaccess + variable in path

     
11:21 pm on Aug 10, 2012 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 5, 2003
posts: 156
votes: 0


Ok... htaccess I love it and hate it.

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 want to redirect all images from each of the /images/u/ to:

root/newimagedir

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

Thanks in advance.
11:34 pm on Aug 10, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


Write the RegEx pattern for the rule so that it selects the one you want to redirect and does not select the ones you don't. If necessary add an additional RewriteCond looking at REQUEST_URI.

You'll end up with a ruleset that works when URL "begins with this" but does "not contain this", or similar.