• 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 site.com/child but neees to be site.com/parent/child.

    Look at one of the old sites, I see that the menu does go to site.com/parent/child, but if I put in site.com/child, it redirects to site.com/parent/child.

    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: https://www.pennsylvaniamalpractice.com/
    New site: https://pennsylvaniamalpractice.com.php53-5.ord1-1.websitetestlink.com/

    Thanks in advance!
    Beth

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?

    Thread Starter cyberinfinity

    (@cyberinfinity)

    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).

    Thread Starter cyberinfinity

    (@cyberinfinity)

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

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

    Thread Starter cyberinfinity

    (@cyberinfinity)

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

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

    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.

    Thread Starter cyberinfinity

    (@cyberinfinity)

    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 – https://www.lowabram.com – instead of the temp ULR, but I’m still having the same problem, that the links are requiring the parent slug.

    https://www.lowabram.com/auto-accidents should be redirecting to
    https://www.lowabram.com/practice-areas/auto-accidents 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

    domain.com/parent/child/ you get redirected to domain.com/parent/child/

    What could be different here?

    Thread Starter cyberinfinity

    (@cyberinfinity)

    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.

    Thread Starter cyberinfinity

    (@cyberinfinity)

    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?

    Thread Starter cyberinfinity

    (@cyberinfinity)

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

    Working:
    https://www.philadelphiamedicalmalpractice.com

    Not working:
    https://www.philadelphiamedicalmalpractice.com.php53-5.ord1-1.websitetestlink.com/

    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.