tags:

views:

9

answers:

1

Hi,

I have done few changes and unable to get my images resolved correctly.

Old = http://www.domain.com/dir/images/*.jpg

New = http://www.domain.com/old_dir/images/*.jpg

I am using the following RewriteRule,

RewriteRule ^dir/images/(.*)\.jpg$ old_dir/images/$1\.jpg [R=301]

Doesn't work, any pointers on how to get to work the images resolved correctly ?

Thanks

A: 

I suspect your

RewriteRule ^dir/images/(.*)\.jpg$ old_dir/images/$1\.jpg [R=301]

should be

RewriteRule ^/dir/images/(.*)\.jpg$ /old_dir/images/$1\.jpg [R=301]

The ^ signifies an anchor at the beginning, and your anchor followed by the dir excludes the required leading /

See the apache docs for details.

Debugging Steps

As far as specific steps for debugging you could try:

  1. RewriteRule ^.*$ /test.html [R=301] to make sure the rewriting engine is actually working.
  2. If that works, you can try an absolute uri instead of a regex one: RewriteRule ^/dir/images/image1.jpg$ /old_dir/images/image1.jpg [R=301]
  3. If that works, you can try tweaking the regular expressions to make sure you're getting them right.

Are there any indications that the re-writing is happening at all? Is the URL in the browser being rewritten at all?

John Weldon
I tried. Didn't work.
Chetan
Updated with some trouble shooting steps.
John Weldon