Support » Fixing WordPress » Redirecting subfolder to another with postname permalinks

  • Resolved kput


    I have a custom post type of ‘artist’ and a custom taxonomy of ‘artists’. My permalinks are set up to the ‘postname’ option.

    Without using a plugin, I need to redirect this:
    to this (for all postnames):

    I have setup the archive.php page and the single-artist.php page to look and respond identically therefore I would like to send everything to the archive page or vice versa. (there are other reasons but are irrelevant to my question here).

    ‘Redirect 301 /artist /artists’ does not seem to be working. Is this possible with the postname permalink structure?

Viewing 6 replies - 1 through 6 (of 6 total)
  • try: Redirect 301 /artist/* /artists/*

    This does not seem to work either.

    There is the generated wordpress code in my .htaccess file. Should my Redirect 301 go above, below, or within that wordpress generated code? I’ve tried all three but I need clarification to make sure I’m doing this right. I’m appending the code to the .htaccess file in the wordpress install folder which contains wp-content, wp-admin etc. Correct?

    Still no luck with the .htaccess however I was able to accomplish this task by using only this code in my single-artist.php file:

    $artist_slug = $post->post_name;
    $siteurl = site_url();
    $location = $siteurl . '/artists/' . $artist_slug;
    wp_redirect( $location, 301 );


    below the generated code by wordpress.
    that is correct. you should edit the .htaccess on the root folder of the site.

    Sorry about the code.
    I did found a way to your problem:
    Try this code:

    RedirectMatch 301 /artist/(.*)$1

    That works for me.
    This code also redirect /artist/ to /artists/

    Thank you, this works!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Redirecting subfolder to another with postname permalinks’ is closed to new replies.