I had a custom post type with slug as (sometext) which I changed to (someothertext) And it works great

So for example :

my posts with urls like


gets redirected to


but not my archive page

basically I would like to redirect

http://localhost/sometext/ to

in my .htaccess file I tried adding a string to make it work

RewriteRule ^/sometext$ ^/someothertext/$ [R=301,L]

but it fails.

I'm very poor with .htaccess rewrites. I'll really appreciate if someone helps me out with this.


2 Answers 2


The link to the archive page is saved into WordPress rewrite rules. These rules are used to locate several locations on the front end of your WordPress system. When you change the slug of a Custom Post Type, the normal pages will redirect directly to the new location, but the archive page won't, this because the rewrite rules aren't regenerated.

To solve this, go to Settings -> Permalinks and save your permalink structure again, reload your page and the archive page will load correctly.

The rewrite rule in your .htaccess won't be needed.

Also, never put any rewrite rules in your .htaccess except the ones WordPress writes into it. If you want to add some rules, do this by using the Rewrite API.

  • hi Mike, thanks for your reply. I'm afraid it does not work. As i said in my question urls to my posts are getting redirected successfully but not for archive pages. (I already flushed rewrite rules by visiting Settings -> Permalinks) Jan 28, 2013 at 11:08
  • Do you have the argument has_archive in the register_post_type function on true, or on sometext? It could it be that you'll have the archive manual directed to sometext? Jan 28, 2013 at 11:21
  • yes mike 'has_archive' is set to true, and not set as sometext. I also tried changin 'has_archive' => 'someothertext' but still it returns 404 Jan 28, 2013 at 11:52

As it was mentioned. Never put any rewrite rules in your .htaccess, use Rewrite API instead. To reach your goal, use following code in your functions.php or site-specific plugin:

add_action( 'generate_rewrite_rules', 'my_rewrite_rules' );
function my_rewrite_rules( $wp_rewrite )
    $wp_rewrite->rules = array(
        'sometext/(.+?)/?$' => $wp_rewrite->index . '?someothertext='.$wp_rewrite->preg_index( 1 ),     
        'sometext/(.+?)/([0-9]{1,})/?$' => $wp_rewrite->index . '?someothertext='.$wp_rewrite->preg_index( 1 ). '&paged=' . $wp_rewrite->preg_index( 2 ),               
    ) + $wp_rewrite->rules;

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.