开发者

Resolving Images after URL Changes - .htaccess

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


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜