Replacing key in ${QUERY_STRING} via .htaccess | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Replacing key in ${QUERY_STRING} via .htaccess

Hello together! Could someone please give me a tip how to replace the key in a query string but keep the value (in this case the value is allways a hash)? Basically it want to do that: index.php?OLDKEY=(hash) -> index.php?NEWKEY=(hash) Right now i have something like that in my .htaccess: RewriteCond ${QUERY_STRING} ^OLDKEY=(.*)$ RewriteRule index\.php /index.php?NEWKEY=$1 ... but this does not work :/ Could someone give me a hint how i could do this? Thanks alot!

2nd Mar 2018, 9:52 AM
Markus
Markus - avatar
1 Answer
0
... i found it out by myself. My rule looks like that: RewriteCond %{QUERY_STRING} ^OLDKEY=([^&]*) [NC] RewriteRule ^index\.php$ %{REQUEST_URI}?NEWKEY=%1 [L,NC,R=301]
6th Mar 2018, 8:29 AM
Markus
Markus - avatar