WordPress.org

Support

Support » How-To and Troubleshooting » How does wordpress know to 301 redirect on post change

How does wordpress know to 301 redirect on post change

  • KurtMoore
    Member

    @kurtmoore

    Baffled, I just went into wp-admin and changed the Post Slug to something new, this was reflected in the url, so it is example.com/my-new-post-slug
    The old one was example.com/bad-name

    Whats nice, is if I go to the old one, I get a 301 redirect, but I have no idea how WP is pulling this off. Looking at the DB schema, I see nothing in there that could allow it to know this. I toggled off all my plug-ins so I know those are not doing this either.

    How does this work?

Viewing 2 replies - 1 through 2 (of 2 total)
  • kaldari
    Member

    @kaldari

    Apparently, when you change the slug, WordPress creates an entry in the postmeta table with the meta_key “_wp_old_slug” that associates the old post slug with the correct post id. Pretty clever.

    SgrWd
    Member

    @adamf24

    Wow I just tried this out myself and I too was baffled. That is damn clever! I love wordpress!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How does wordpress know to 301 redirect on post change’ is closed to new replies.