2

want to redirect some links from oldsite to new one and doing like this:

Redirect 301 /benefits  http://newsite.com/our-differiantiators/
Redirect 301 /benefits/our-people http://newsite.com/about-us/
Redirect 301 /benefits/our-places http://newsite.com/infrastucture/
Redirect 301 /benefits/our-platforms    http://newsite.com/infrastucture/
Redirect 301 /benefits/our-experience http://newsite.com/
Redirect 301 /benefits/our-testimonials http://newsite.com/

but if i try to go to my newsite.com/benefits/our-people it redirecting to newsite.com/our-differiantiators/our-people not newsite.com/about-us

how should I fix my .htaccess code to redirect like I want?

P.S. maybe it's because slug /our-people and /our-differiantiators and wordpress somehow is handling that?

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
Scorpioniz
  • 1,421
  • 3
  • 16
  • 36
  • 1
    If you remove the first like, it works OK? Try that (to see what's going on), and then try changing it by this line: `RedirectMatch /benefits$ http://newsite.com/our-differiantiators/ [R=301,L]` – ishegg Feb 13 '18 at 15:04
  • nope.. it's not working.. it still redirects me to `newsite.com/our-differiantiators/our-people` ... mybe it's because slug `our-people` and `our-differiantiators` and somehow wordpress is handling that? – Scorpioniz Feb 13 '18 at 15:12
  • @ishegg no [R=301,L] with RedirectMatch it is mod_alias – Mohammed Elhag Feb 13 '18 at 15:13

2 Answers2

4

change this line :

Redirect 301 /benefits  http://newsite.com/our-differiantiators/

by this :

RedirectMatch  301 /benefits/$  http://newsite.com/our-differiantiators/

With RedirectMatch you will match only benefits/ ,ended with slash, directory when it comes alone otherwise the other rules will work

Mohammed Elhag
  • 4,272
  • 1
  • 10
  • 18
2

Try to write: Redirect 301 /benefits http://newsite.com/our-differiantiators/ at the end of file;

Or you can change the first line with: RedirectMatch ^/benefits$ http://newsite.com/our-differiantiators/

vpalade
  • 1,427
  • 1
  • 16
  • 20
  • same result as if it is at the top of the file :/ – Scorpioniz Feb 13 '18 at 14:57
  • Remove from the beginning and add at the end. I tried and it works, you saved the .htacceess file? – vpalade Feb 13 '18 at 15:07
  • nope.. it's not working.. it still redirects me to newsite.com/our-differiantiators/our-people ... mybe it's because slug our-people and our-differiantiators and somehow wordpress is handling that? – Scorpioniz Feb 13 '18 at 15:13