Reputation: 97
Help!!, I have tried by best more than a day trying to fix this, Please I want to redirect all search query url within a category and also removing the / sign from the url using htaccess e.g example.com/stack/?s=keyword/
to example.com/stack/?s=keyword
I have tried the below code but its only redirecting example.com/?s=keyword/
to example.com/?s=keyword
but it is not working when I include the category url to the permalink.
RewriteCond %{QUERY_STRING} ^s=([^&]+)/$
RewriteRule ^$ /?s=%1 [L,R=301,NE]
Please I need help here please I beg of you please.
thanks in advance.
Upvotes: 1
Views: 14
Reputation: 785581
Try this rule as your topmost rule:
RewriteEngine On
RewriteCond %{THE_REQUEST} (/stack/\?s=[^&\s]*)/\s [NC]
RewriteRule ^ %1 [L,R=301,NE]
Upvotes: 1