• Home
  • Jobs
  • Courses
  • Teachers
  • For business
  • Blog
  • ES/EN

0

7
Views
RewriteCond fetch array parameters from Query_String and convert into path while retaining the remaining parameters

How to allow few parameters to continue to be redirected while one paramter which is an array to be converted into a string in the url path

example: param1[]=apple&price=1,10 should become /apple/?price=1,10

Orginal url: example.com/path1/?param1[]=apple&param2=1,100
Expected redirection: example.com/path1/apple/?param2=1,100

Orginal url: example.com/path1/path2/?param[]=apple&param2=1,100&param3=yes
Expected redirect: example.com/path1/path2/apple/?param2=1,100&param3=yes
10 days ago ·

Santiago Trujillo

1 answers
Answer question

0

You may use this redirect rule that will handle param1[]= query parameter anywhere:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?param1\[\]=([^&]*)(?:&(.*))?$ [NC]
RewriteRule ^(.*?)/?$ /$1/%2?%1%3 [R=301,NE,L]
10 days ago · Santiago Trujillo Report
Answer question
Remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Startups
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.