Skip to:
Content
Pages
Categories
Search
Top
Bottom

/blogs/?random-blog redirects then WP redirects

  • I’m trying to track down what is causing this – but so far seem to have no luck.

    1: clicking Random Blog redirects to a random blog

    2: WordPress MU then redirects to a post on the main site using the slug ‘blogs*’ to find my post called ‘Blogs and Social Networking’ and uses a 301 Permanent to do so.

    I initially thought WordPress was finding an old slug within wp_1_postmeta and have checked to see if the post had an old slug – but found nothing.

    Just in case, I also disabled the wp_old_slug_redirect function by making it return straight away and still no luck.

    I was wondering if anyone else has had (or having) similar problems or if anyone has any ideas on where else I should look to track down this behavior.

Viewing 15 replies - 1 through 15 (of 15 total)

  • gogoplata
    Participant

    @gogoplata

    Sounds similar to a problem I ran into. I had a user create an account with the name “justin” but domain.com/members/justin redirected to a post with a slug starting with justin rather than the user profile. Not exactly the same problem, but sounds like they’re related. I’m planning on investigating this soon, but if it’s widespread hopefully Andy can check it out as well.

    To solve it in the near term I just renamed the post so it didn’t start with Justin and everything worked fine, but I’m likely to encounter this again.

    Thanks for the reply,

    I will continue to look into the cause and effect of this strange behavior too, but in the mean time I have renamed my offending post and all is well once more.

    I have BuddyPress set up both on locally and a live server so I am able to test/tweak/hack etc

    Here are some things I will test to try and replicate this.

    1. Create a post called Blogs [something] on the main site so the slug reads blogs-[something]
    2. Create a similar post on a fake users blog with a similar name/slug of that above.

    I tried to duplicate this on [myblog].testbp.org but all seemed normal, so I have a feeling it will only happen on the main blog.


    gogoplata
    Participant

    @gogoplata

    Yeah, it seems to only occur with posts on the main blog. Not going to be a problem for a lot of sites where their posts are mainly on a sub-blog but my site has 2,000+ posts so I have a feeling I’ll run into this again. I’m going to try to find a solution as well, though disabling the redirection might be a temporary solution.


    Alessandro Fazzi
    Participant

    @pioneerskies

    Same problem here! ^_^ If I try to go to a random blog, bp sends me to a post of the main blog with the word “blog” in its slug…


    gogoplata
    Participant

    @gogoplata

    Definite bug then, I’ll create a ticket in a few.


    Alessandro Fazzi
    Participant

    @pioneerskies

    I can add this: I have a member domain.net/members/ken. If I go there it bring me to a post with “ken” in the slug: domain.net/2008/1/kenya. So I’m definitively sure about the bug…


    Alessandro Fazzi
    Participant

    @pioneerskies

    Damn! I’ve a lot of conflicting usernames/slugs!!!! Heeeelp! :P


    Alessandro Fazzi
    Participant

    @pioneerskies

    Woooohoooo! I’ve figured it out how to make it work for now: all works well if the permalinks are in the default format!

    Try it out guys…

    I have been doing a little more digging into this problem and the same bug effects:

    • domain.com/blogs/*
    • domain.com/groups/*
    • domain.com/members/*

    For instance, you have a post on your main blog called ‘testing BuddyPress’, and someone creates a group called ‘test’ – each time you try to access that group, WordPress will magically use its rewrite rules class and send you to the post entry.

    To start with, I thought it may have been a WordPress bug, but no… its WordPress’ default behavior.

    It seems that currently BuddyPress is doing its own URL rewriting and then WordPress takes over to convert domain.com/anything/you/like/except/THIS to find ‘THIS‘ as a possible candidate for a place to be.

    I have no experience using the correct methods of plugging into the WordPress rewrite rules structure and I am still getting familiar with the ins and outs of BuddyPress – but I hope to keep people posted on my findings.

    Firstly, https://codex.wordpress.org/Function_Reference/WP_Rewrite makes it sound simple to utilise the correct and preferred WordPress ways of doing things correctly.

    Secondly, If this is the case – it is a good job this has been spotted early because I have a feeling that fixing BuddyPress to use the above would require some core changes.

    For anyone interested in the way WordPress looks at its URL’s, paste the following into the <body> of your test theme’s header.php

    <pre>
    <?php global $wp_rewrite;
    print_r($wp_rewrite);
    ?>
    </pre>'

    The important part to look at is [rules] => Array that has no mention of blogs, groups or members.

    Anyways…

    I will continue getting to grips with BuddyPress internals and reporting my findings…

    I hope this has helped someone getting closer to fixing!

    BuddyPress is doing its own thing.

    Take a look at bp-core/bp-catch-uri.php

    The URL is split up into variables and used within plugins. This is obviously interfering with some of the WordPress URL’s. I’m going to take a look at this and see if there is a solution to put pages on a exclude list.

    I think I’ve fixed it.

    When using the BuddyPress function bp_core_do_catch_uri() via the ‘template_redirect’ action, there needs to be a remove_action() on redirect_canonical() to stop the BuddyPress redirection and WordPress redirection conflicting.

    Basically adding a remove action on line 158 of bp-core-catchuri.php seems to work:

    remove_action( ‘template_redirect’, ‘redirect_canonical’ );

    add_action( ‘template_redirect’, ‘bp_core_do_catch_uri’ );

    This seems to fix the problem of conflicting page names/group names.

    Revision 571 seems to have fixed the problem here too, I am glad that WordPress action hooks go a little further than I realised.

    I just seem to have a problem with random blogs throwing a 404 on the main site now… but as its the weekend, not had chance to look any deeper.

    Good work Andy :)


    gpo1
    Participant

    @gpo1

    @deadpan110, sorry to jump in but I like your site and I want to know what hosting your using shared or vps for your site ?


    gogoplata
    Participant

    @gogoplata

    Thanks for the fix Andy. Seems like you’ve been busy lately, but it’s much appreciated.


    Alessandro Fazzi
    Participant

    @pioneerskies

    Terrific! I’ll try it out ASAP!

    Thanks Andy!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘/blogs/?random-blog redirects then WP redirects’ is closed to new replies.
Skip to toolbar