: Rewrite Rule for Manipulating Query parameter - middle value in long Query Value Trying to achieve Source - https://rrr.rrr.com/us/Product-Family/Products/c/Products/layout?layoutType=false&page=0&grid=true&q=:relevance:Dr
Trying to achieve
Source -
rrr.rrr.com/us/Product-Family/Products/c/Products/layout?layoutType=false&page=0&grid=true&q=:relevance:DriveType:Flash:ProductFamily:Prd 1
To
rrr.rrr.com/us/Product-Family/Products/c/Products/layout?layoutType=false&page=0&grid=true&q=:relevance:DriveType:Flash SSD:ProductFamily:Prd 1
trying to find and replace DriveType:Flash to DriveType:Flash SSD anywhere in Query String
Problem is that DriveType:Flash SSD can appear anywhere in the Query String
More posts by @Annie201
1 Comments
Sorted by latest first Latest Oldest Best
Try the following in .htaccess:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)DriveType:Flash:(.*)$
RewriteRule ^us/Product-Family/Products/c/Products/layout$ /[CO]?%1DriveType:Flash SSD:%2 [R=301,L]
This only matches the URL specified and externally redirects to the new URL. This could perhaps be made more efficient by restricting the pattern that will match before and after the required string. At the moment .* matches anything (and nothing).
In the RewriteRule substitution: [CO] is the entire string/URL matched by the RewriteRule pattern and %1 and %2 are the corresponding sub patterns in RewriteCond matched before and after the required string to replace.
Note that I've included the : at the end of the pattern to avoid a rewrite loop. If the pattern does not always end with a : then this will need to be changed.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.