Forum Moderators: phranque
Incoming URL:
http://www.example.com/my/app?id=20&dn5=abc&attr=xyz
Need to rewrite URL to:
http://www.example.com/my/app?id=20&dn1=abc&attr=xyz
So, I just want to replace the dn5 with dn1.
In my .htaccess I have tried:
RewriteEngine On
RewriteCond %{QUERY_STRING} (.*)dn5=(.*)
RewriteRule ^/my/app$ /my/app?%1dn1=%2 [L]
Obviously this isn't working. I have played with using the R flag as well.
RewriteCond %{QUERY_STRING} ^(([^&]+&)*)dn5=([^&]+)((&[^&]+)*)$
RewriteRule ^my/app$ /my/app?%1dn1=%3%4 [L]
Assuming you're not getting 500-Server Error, that this code is located in the root .htaccess file at example.com/.htaccess, that you've got MultiViews (content negotiation) disabled, AcceptPathInfo Off, all browser and network caches have been flushed so that the request reaches your server, and that the URL you are requesting is example.com/my/app?blah&dn5=<value>&blah, then this rule will rewrite to /my/app?blah&dn1=<value>&blah
Jim
[edited by: jdMorgan at 1:09 am (utc) on June 27, 2009]