WordPress.org

Ready to get started?Download WordPress

Forums

How does wordpress know to 301 redirect on post change (3 posts)

  1. KurtMoore
    Member
    Posted 7 years ago #

    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?

  2. kaldari
    Member
    Posted 7 years ago #

    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.

  3. SgrWd
    Member
    Posted 6 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic