I want to rewrite some dynamic urls like:
https://www.test.com/my-custom-url.html/?o=price&dir=asc&new=1
to
https://www.test.com/my-custom-url.html/o/price/dir/asc/new/1
Thanks.
I want to rewrite some dynamic urls like:
https://www.test.com/my-custom-url.html/?o=price&dir=asc&new=1
to
https://www.test.com/my-custom-url.html/o/price/dir/asc/new/1
Thanks.
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]
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