.htaccess redirect for images only

I’m having an issue on my site that requires me to temporarily redirect all requests for images within a particular directory (and its nearly 100 sub-directories) to the same image in a separate directory/sub-directory. Image and sub-directory names are the same; only the main directory name is different.

Unfortunately, I’m having trouble getting the rewrite rule set up correctly in my .htaccess file. I can redirect to a static location fine, but the sub-directories are messing me up. How can I set this up to work correctly?

Hi Matt,

Seems like a reasonable question but you’ve not shown the code you’re attempting to use. I suspect that it is requiring specific a hard coded directory with the file name (look for the start anchor, the ^) rather than leaving the start open ended. If you can simply identify the filename (without regard to the path), you can easily redirect the request to the appropriate location (even if it’s in another domain … AND you don’t use anti-leaching code).

If that didn’t resolve it for you, please post your mod_rewrite code AND an example of the link to an image file.

Regards,

DK

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.