Reputation: 3
I have an ajax plugin for searching products in my store that automatically inserts a parameter in the URL, breaking the query.
Since this "feature" is hardcoded and can't really modify the plugin myself, I would like to implement a rewrite rule in oder to make:
https://mywebsite.com/?s=MySearchTerm&post_type=product&dgwt_wcas=1
Become
https://mywebsite.com/?s=MySearchTerm&post_type=product
hence removing &dgwt_wcas=1
from all URL's if present.
How can I setup a rewrite rule to accomplish this?
Upvotes: 0
Views: 298
Reputation: 179
Try with this code
RewriteEngine on
RewriteCond %{QUERY_STRING} ^(.*)&?dgwt_wcas=[^&]+&?(.*)$ [NC]
RewriteRule ^/?(.*)$ /$1?%1%2 [R=301,L]
Upvotes: 3