mod_rewrite per-dir redirection returning a 400
Posted
by
Eaterrust
on Stack Overflow
See other posts from Stack Overflow
or by Eaterrust
Published on 2010-12-29T20:51:36Z
Indexed on
2010/12/29
20:54 UTC
Read the original article
Hit count: 156
I moved my images directory to a different folder, and now I want to redirect all images requests from that folder to the new one. I do not have access to the main configuraion file, so I'm doing this in a .htaccess.
I tried this, and it works: RewriteCond %{REQUEST_URI} old_dir/.+.(jpg|png|gif)$ RewriteRule old_dir/(.+[^/]+..+)$ $1 [L,PT]
But since they have permanently moved, I want to do a proper redirect, so I added the [R] flag, like this: %{REQUEST_URI} old_dir/.+.(jpg|png|gif)$ RewriteRule old_dir/(.+[^/]+..+)$ $1 [L,PT,R]
But the server gets confused, and returns a 400, so I looked at the log file, and this is what happens: strip per-dir prefix: C:/wamp/www/natrazyle/old_dir/images/banner.jpg -> old_dir/images/banner.jpg applying pattern 'old_dir/(.+[^/]+..+)$' to uri 'old_dir/images/banner.jpg' rewrite 'old_dir/images/banner.jpg' -> 'images/banner.jpg' add per-dir prefix: images/banner.jpg -> C:/wamp/www/natrazyle/images/banner.jpg explicitly forcing redirect with http://localhost/C:/wamp/www/natrazyle/images/banner.jpg
As you can see, the full local path gets added after localhost
I know I'm doing something wrong, I just can't figure it out myself. Any help would be greatly appreciated...
© Stack Overflow or respective owner