WordPress.org

Ready to get started?Download WordPress

Forums

Automatically redirect .../child to .../parent/child? (13 posts)

  1. cyberinfinity
    Member
    Posted 12 months ago #

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

    Thanks in advance!
    Beth

  2. martha_camellia
    Contributor Day Volunteer
    Posted 12 months ago #

    Hi Beth:

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

  3. cyberinfinity
    Member
    Posted 12 months ago #

    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.

  4. martha_camellia
    Contributor Day Volunteer
    Posted 12 months ago #

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

  5. cyberinfinity
    Member
    Posted 12 months ago #

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

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

  6. cyberinfinity
    Member
    Posted 11 months ago #

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

  7. cyberinfinity
    Member
    Posted 11 months ago #

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

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

  8. cyberinfinity
    Member
    Posted 11 months ago #

    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?

  9. martha_camellia
    Contributor Day Volunteer
    Posted 11 months ago #

    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.

  10. cyberinfinity
    Member
    Posted 11 months ago #

    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?

  11. martha_camellia
    Contributor Day Volunteer
    Posted 11 months ago #

    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?

  12. cyberinfinity
    Member
    Posted 11 months ago #

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

    Working:
    http://www.philadelphiamedicalmalpractice.com

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

  13. martha_camellia
    Contributor Day Volunteer
    Posted 11 months ago #

    Can you compare the old and new .htaccess files?

Reply

You must log in to post.

About this Topic