0

I want to redirect an url with multiple parameters and rename the parameters keys:

From

 www.site.it/index.php?par1=1&lang=en_US

to

 www.site.com/index.php?parameter1=1&languages=en_US

I tried with this:

RewriteCond %{QUERY_STRING} par1=([0-9]+)
RewriteCond %{QUERY_STRING} lang=en_US
RewriteRule ^index.php site.com/index.php?parameter1=$1&lang=en_US [R=301,L]

But it failed.

1
  • lang is always the 2nd. Commented Mar 30, 2015 at 15:19

1 Answer 1

1

You can use:

RewriteCond %{QUERY_STRING} par1=(\d+)&lang=([^&]+)
RewriteRule ^index\.php http://www.example.com/index.php?parameter=%1&languages=%2 [R,L]

%1 and %2 are references to the capture groups in the query string regex

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.