Like Me? Follow Me.
RewriteRule ^blog-blog-title-(14)\.html$ blog.php?id=$1 [L]
But recently I had to do the process in reverse which seemed straightforward:
RewriteCond %{QUERY_STRING} id=14
RewriteRule ^blog\.php$ blog-blog-title-14.html [L]
But when the rule was invoked, this happened:
blog-blog-title-14.html?id=14
mod_rewrite was attaching the query string automatically, assuming this was the behaviour I was looking for. After spending a long time Googling various things to try and find an answer (and finding precious little to help me, even on webmaster help forums such as ExpertsExchange) I came up with nothing. It's almost as if nobody had attempted this before.
After some intensive really obscure searches I managed to find the not so straightforward solution which I could not find anywhere in the Apache docs. The solution is to stick this string (I have no idea what it does or why it works, but it does) after your mapped url:
${pages:%1¦NULL}?
Example:
RewriteCond %{QUERY_STRING} id=14
RewriteRule ^blog\.php$ blog-blog-title-14.html${pages:%1¦NULL}? [L]
This little string is nowhere near publicised enough nor is it easily searchable on Google, so I hope that I can help to spread the word by mentioning it here.



