1 Answer 1

0

You can rewrite a query string like this:

Example for one arbitrary parameter:

RewriteCond %{REQUEST_URI} ^/my-custom-url.html.*$
RewriteCond %{QUERY_STRING} ^(.*)=(.*)$
RewriteRule .* /my-custom-url.html/%1/%2? [R=301,NC,L]

Example for 3 arbitrary parameters:

RewriteCond %{REQUEST_URI} ^/my-custom-url.html.*$
RewriteCond %{QUERY_STRING} ^(.*)=(.*)&(.*)=(.*)&(.*)=(.*)$
RewriteRule .* /my-custom-url.html/%1/%2/%3/%4/%5/%6? [R=301,NC,L]
answered Jun 2, 2020 at 8:57
2
  • It replaced the URL well but now I am not able to get these parameter values via $_GET or $_REQUEST Commented Jun 2, 2020 at 9:36
  • OK, that was not part of your question :-) For that you need an additional line, for example this for one parameter: RewriteRule ^/my-custom-url.html/[a-z]+/[a-zA-Z0-9-]+$ my-custom-url.html?1ドル=2ドル [L] Important: this should not redirect! Put it above the other rule I'm not sure about this, it might end in an infinite loop Commented Jun 2, 2020 at 10:21

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.