A
A
applecode2018-09-01 18:16:02
htaccess
applecode, 2018-09-01 18:16:02

How to rename GET parameters in page url in .htaccess?

How to rename get parameters to url?
For example ?name=user in ?nickname=user, regardless of their location. They can go both as the first parameters and as the last ones. For example, ?price=20&name=user should also be renamed to ?price=20&nickname=user
RewriteCond %{QUERY_STRING} ^name=(.*)$ [NC]
With this line, I get the parameter value so that I can use it later with %1
But I can’t figure out how to make a replacement now.
Thanks a lot

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2018-09-01
@applecode

RewriteCond %{QUERY_STRING} ^(|.*?&)name(=.*)$
RewriteRule ^(.*)$  /$1?%1nickname%2 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question