Caipiranha
Caipiranha

Reputation: 55

301 FROM URL with parameters TO URL with parameters

I cannot find a case with both sides (src and target) with parameters,

I need to make a 301 from:

www.example.com/test-test/test.html?subcats=Y&features_hash=V231

to

www.example.com/test-test/test.html?features_hash=18-231

Upvotes: 0

Views: 79

Answers (2)

alexeevdv
alexeevdv

Reputation: 31

You can try something like this:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^subcats=Y&features_hash=V(231)$
RewriteRule /test-test/test.html /test-test/test.html?features_hash=18-%1 [R=301,L]

Actually this can be done in one RewriteRule but this rule will be too long

Upvotes: 1

anubhava
anubhava

Reputation: 786359

You can use this rule in /test-test/.htaccess:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.*?/test\.html\?subcats=Y&features_hash)=V(\d+) [NC]
RewriteRule ^ /%1=18-%2 [R=301,L]

Upvotes: 0

Related Questions