Forum Moderators: phranque
I'm in the process of changing photo blogs, but because I'm getting around 5k hits a day I want the old URIs to map to the new ones.
Example:
http://www.example.com/displayimage.php?pos=-11 maps to:
http://www.example.com/index.php?showimage=17
Also there are two other alternate URIs for each image:
http://www.example.com/displayimage.php?pid=-11&fullsize=1
and
http://www.example.com//albums/quotes/kingquote.jpg
So far I have got this working for the first URI:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^pos=-11$
RewriteRule (.*) /index.php?showimage=29? [r=301,nc]
Is there a way to combine the request for the alternate displayimage.php?pid=-11&fullsize=1 on the same line as the ^pos=-11$ rule?
If I could also add in the kingquote.jpg then I would be 'cooking on gas' as they say.
Thanks.
Rog.
If it were me, I would link to the shorter URL internally, and make sure that all URLs with index.php in them are redirected to the version without it, whilst retaining all the parameters.
RewriteEngine On
#
RewriteCond $1>%{QUERY_STRING} ^displayimage\.php>(pos=-11¦pid=-11&fullsize=1)$ [OR]
RewriteCond $1 ^albums/quotes/kingquote\.jpg$
RewriteRule (.*) /index.php?showimage=29 [R=301,L]
If you get a lot more of these you need to redirect in the future, then there are a couple of ways to use a more "table-like" structure. But both are unnecessarily complex if you only have a handful of these URL variants to redirect.
Jim
I'll continue my studies of the 'Definitive Guide to Apache mod_rewrite' that I have and see what other illumination I can get from it.
Thanks your help is very much appreciated!
Rog.
ps.
Anyway I can make a tiny donation to your cause?
[edited by: B16Enk at 8:42 pm (utc) on Sep. 1, 2008]