Support » Fixing WordPress » Automatically redirect …/child to …/parent/child?

  • I’m working on a redesign of 4 related sites, which I didn’t build. We just launched the main site, and then found a ton of broken links, which were fine in the old site. (Link checker running on both.)

    In all instances, the problem is that the link is but neees to be

    Look at one of the old sites, I see that the menu does go to, but if I put in, it redirects to

    How are they making this happen on the old sites, so I can implement it on the new sites?

    I suspect there’s some checkbox somewhere that I’ve missed, but I’ve not found any plug-ins running that I don’t have on the new site, and the permalinks settings match, so I don’t know where else to look.

    Old site:
    New site:

    Thanks in advance!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Hi Beth:

    In your General / Settings admin page, what are your WordPress Address and Site Address settings?

    Both fields are the same as the URLS I listed above for the two sites, respectively, but no trailing / on either one.

    The new site was an automated installation via the host, and both those fields are grayed out. I don’t remember running into that before.

    If those settings are greyed out it could be because those settings are being overridden by WP_SITEURL and WP_HOME in your wp-config.php file. Plugin conflicts can also cause this.

    However, if these settings are correct, try resetting your permalinks by going to Settings/Permalinks and choosing Save (even though you are not changing other settings on that page).

    I can check the config file, or the database directly.

    What do I want them to be, to make this work?

    It’s not being hard coded in wp-config; this is the only reference:

    define(‘WP_HOME’, ‘http://’ . $_SERVER[‘HTTP_HOST’]);
    define(‘WP_SITEURL’, ‘http://’ . $_SERVER[‘HTTP_HOST’]);
    define(‘WP_CONTENT_URL’, ‘/wp-content’);

    Upon further investigation, I see that they’re grayed out on all 4 associated sites. They were all auto-installs. I’m going to contact the hosting company, or the installer and see what’s up.

    The hosting company just pointed me to the instructions for how to hard code it in wp-config, or use functions.php to change it.

    I now have it hard coded to the actual domain – – instead of the temp ULR, but I’m still having the same problem, that the links are requiring the parent slug. should be redirecting to but instead, I’m getting a 404.

    Looking at another WP site I’ve recently set up (different host, also an auto-install), I’ve got those settings the same (the domain for both, no trailing / ) and it works, if you go to you get redirected to

    What could be different here?

    Should there be something in .htaccess to make this redirect happen?

    I had to edit .htaccess to increase the upload file size limit to import the old data; maybe I deleted something that should’ve been there when I added the code to do that?

    A few ideas:

    – Do you only have a few “parent” categories? If so there could have been specific entries in .htaccess for each.

    – There are plugins that handle URL redirects – is it possible one of your old plugins is not activated or has different settings than originally? Sometimes these are specific redirect plugins and sometimes they are part of SEO plugins.

    – WordPress has a feature called automatic redirection whereby if it can’t find a page it will look for another with a “similar” URL and deliver it. It could be working differently on the old and new sites.

    There are tons of parent / child pages, and I think it should be happening automatically. It is on on other WP sites.

    Are your WP sites doing this redirect the way I think it ought to work?

    Any idea where/how that automatic redirection is being controlled? Something screwy there, maybe?

    Yes, I do have a site that redirects in this way.

    I also have a site that I did _not_ want to redirect in this way and I overrode the WordPress behavior by using code like this in functions.php:

    ‘add_filter( ‘redirect_canonical’, ‘remove_redirect_guess_404_permalink’ ,10, 2);
    function remove_redirect_guess_404_permalink( $redirect_url, $requested_url ) {
    if ( is_404() ) {
    return false;
    else {
    return $redirect_url;

    Do you have an example URL for one of the old sites that does behave as you want?

    I came across a few articles about how to override it like that.


    Not working:

    Can you compare the old and new .htaccess files?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Automatically redirect …/child to …/parent/child?’ is closed to new replies.