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

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/
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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