I have a wordpress website where I want to redirect the tag-page URL’s to a specific post.
This works in .htaccess:
Redirect 301 /tag/hometrainer/ https://www.mywebsite.nl/beste-hometrainer-test
The problem is that when I append ‘/page/2/’ (for example) to the initial url, it is also appended to the redirect url:
https://www.mywebsite.nl/tag/hometrainer/page/2/ redirects to https://www.mywebsite.nl/beste-hometrainer-test/page/2, it should redirect to https://www.mywebsite.nl/beste-hometrainer-test
So I need a "catch all" for everything after "/tag/hometrainer" and this should not be displayed in the redirect url.
This does not work:
RewriteRule ^/tag/hometrainer(.*)$ /beste-hometrainer-test [R=301,L]
I get the "post not found" page.
2
Answers
You can add
?
Add the end of URL to remove any query stringsYou can try with the below code –