0

I'm changing my permalink structure from /%postname%/ to /%category%/%postname%/, it doesn't automatically redirect old urls to new urls, it gives 404 error.

old urls: site.com/post-name/

new urls: site.com/category/post-name/

1
  • The new URLs work though?
    – Tom J Nowell
    Commented Feb 4, 2020 at 17:24

1 Answer 1

1

That's expected. WP doesn't build in redirects from old permalink structures to new, since the before and the after could be so many different ways. You'll need to add your own redirects, which will have to be done one by one, since there's no way for the server to tell what category any given post is in.

If you're using Apache, you can do this in .htaccess, above WP's own rules. You'll want 301 permanent redirects, and in .htaccess you set that up with the old relative path, followed by the new absolute path.

Redirect 301 /apples/ https://example.com/fruit/apples/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.