Hello, I'm doing a major overhaul on a big website. The site has 1000's of images, and they are all in the root directory. I have copied and moved them to a directory called /images/, and plan on changing the image paths on as many pages as I can, but the images are used on several of their sister sites and they probably also get a ton of search engine traffic for those images. Is there a way to do something with htaccess to make it so when an image is pulled up in the root directory, that it looks for it in the "/images/" directory instead? Thanks, Andy
I'm sorry, I should have put this in the Apache Section. I feel really really bad about that. I apologize.
Here is what I found, but it is still not working: RewriteEngine On RewriteBase / # prevent endless loops RewriteCond %{REQUEST_URI} !images/ # capture only the filename RewriteRule ^.*/(.*\.jpg|.*\.gif|.*\.bmp) images/$1 [L,R] Code (markup): Any ideas?
This is the RewriteRule I would use. RewriteRule ^/?([^/]+)\.(jpe?g|gif|bmp|png)$ /images/$1.$2 [R=301] Code (markup): If there's no further rewrites needed within the /images/ directory, I'd turn off the rewriteengine in that directories htaccess to prevent double rewrite tests. RewriteEngine off Code (markup):