On Mon, 9 May 2005 19:58:49 +0000, "Joe Button" alug2@joebutton.co.uk said:
Hi Richard.
I want to make old fashioned URLs like: http://www.sara.uea.ac.uk/search_from_listings.php?artist_id=13 redirect to the new ones: http://www.sara.uea.ac.uk/?artist&id=13
The new ones have a rather odd format. You're not already using some other rewriterule to translate them or something are you?
Not for those ones, no (I've got several URL schemes supporting different past versions which are all implemented as RewriteRules).
This one works because the main PHP script is called index.php (i.e. is automatically started by Apache in the absence of any other file name) and knows how to read the slightly odd (but short) URL.
I don't think you can rewrite urls with querystrings like that. IIUC you need to use rewritecond and %{QUERY_STRING}. Rewriterule doesn't consider the querystring to be part of the URL.
OK, thanks for the tip. I've managed to get it to work:
RewriteCond %{QUERY_STRING} ^artist_id=([0-9]+)$ RewriteRule ^/search_from_listings.php$ http://www.sara.uea.ac.uk/?artist&id=%1 [L]
Thanks very much for your help!
Richard