Forum Moderators: phranque

Message Too Old, No Replies

help with mod rewrite rule design

         

tarmo

4:11 pm on Aug 10, 2006 (gmt 0)

10+ Year Member



I am about to convert my static site to CMS. All images are going to be moved to /owt/ subdirectory.

The question is how to 301 redirect my old images (only images) urls to new locations.

Example:
old url: [mysite.com...]
new url: [mysite.com...]

I have tried the following rule, but it starts to loop.

RewriteEngine on
RewriteRule (.*.jpg) [mysite.com...] [r=301,L]

Can anyone help me with this trivial(?) rule?

Thank you

jdMorgan

4:51 pm on Aug 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need to exclude requests for images in the /owt/ subdirectory, since otherwise, those requests will also match your rule, thus causing your loop:

RewriteEngine on
RewriteCond $1 !owt/
RewriteRule ^(.*\.jpg)$ http://www.example.com/owt/$1 [R=301,L]

Jim

[edited by: jdMorgan at 4:52 pm (utc) on Aug. 10, 2006]

tarmo

8:42 am on Aug 11, 2006 (gmt 0)

10+ Year Member



Thank you.