I changed the name of two of my custom post types. The original slugs for them did not properly reflect the post type. So I need to redirect requests for posts beginning with designer_lingerie (the old post type slug) to just designer. All of the posts are the same just the post type slug has changed.

I am sure I'll need to use .htaccess but am unsure of what to tell it to change. Basically what URL should I use to do this? The WordPress pretty URL or the default URL?

  • I edited the post to include your comment, you can remove the comment if you think it is unnecessary.
    – Jan Fabry
    Commented Jul 11, 2011 at 15:56
  • anytime I add an .htaccess file the Wordpress pretty URLs no longer work. I cannot find a Wordpress generated .htaccess file anywhere on my development server. Any ideas? Anyone? Thanx
    – dkmojo
    Commented Jul 13, 2011 at 15:18

4 Answers 4


All you need to do is add a line like:

RewriteRule ^aboutus$ /about-us [R=301,L]

In to your .htaccess file. The old url should go between the ^ and $ and then new url after the slash.

  • how can I tell if the redirect 301 is active? That the redirect happened and not just a rewrite? Thanx
    – dkmojo
    Commented Jul 13, 2011 at 15:47
  • you can use a tool like Firebug to watch the Network communication when you request a URL. That rule in the .htaccess will respond with a 301 header.
    – Alex Older
    Commented Jul 14, 2011 at 7:17
  • cool thanx. I'll check on the redirect header in firebug
    – dkmojo
    Commented Jul 15, 2011 at 13:14
  • Yep, it's all good! Thanx again
    – dkmojo
    Commented Jul 15, 2011 at 13:24

I would not use the Apache Rewrite module, but the built-in WordPress rewrite functionality. If you want to see the rules it uses, install my Rewrite analyzer plugin. You can just duplicate the rules of your post type, with the old slug instead of the new slug. This way both URLs will link to your post content.

// The filter name is [post type name]_rewrite_rules, so I assume your post type name (not rewrite slug) is `designer`
add_filter( 'designer_rewrite_rules', 'wpse22625_designer_rewrite_rules' );
function wpse22625_designer_rewrite_rules( $rules )
    $old_rules = array();
    foreach ( $rules as $pattern => $substitution ) {
        $old_pattern = str_replace( 'designer', 'designer_lingerie', $pattern );
        $old_rules[$old_pattern] = $substitution;
    return $rules + $old_rules;

This will not generate a redirect - weird, I expected the redirect_canonical() function to do this. You can do it yourself if you want, either by hooking into redirect_canonical, or by setting an extra flag that you check yourself.

  • My old post types no longer exist so would this work for me? I am not sure the benefits of this method. What would the benefit of not using Apache be? Just curiuos, Thanx
    – dkmojo
    Commented Jul 15, 2011 at 13:13

If you change the permalinks but not the underlying structure WordPress should be able to find your posts, since the 'real' url structure is still the same. In other words if you only change the permalinks it should automatically redirect to the right location.

  • I actually changed the post type name. so the underlying URLS are different with the new version of my site. My original post was edited to clarify my question. Thanx again.
    – dkmojo
    Commented Jul 13, 2011 at 13:31

WP retains the corresponding metadata regarding the original non-pretty permalink and any changes to standard permalinks. See http://codex.wordpress.org/Using_Permalinks

If you have non-pretty permalinks in post/page content or leave them hardcoded anywhere, WP will redirect those to the pretty version.

That said, if you change the URL directly in the post/page editor, you do need to redirect. One of the ways to handle that is with a plugin like WordPress › Redirection « WordPress Plugins

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.