skip to Main Content

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


  1. You can add ? Add the end of URL to remove any query strings

    RewriteRule ^/tag/hometrainer(.*)$ /beste-hometrainer-test? [R=301,L]
    
    Login or Signup to reply.
  2. You can try with the below code –

    RewriteRule ^/from-slug(.*)$ /to-slug? [R=301,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search