WordPress.org

Ready to get started?Download WordPress

Forums

WP-No-Tag-Base
[resolved] possible malfunction? (19 posts)

  1. Markus Stefanko
    Member
    Posted 2 years ago #

    Since updating the plugin I am having weird 'too many redirects' errors on any posts I'm entering. The frontpage works fine. I don't see anything in the errors logs, and the access logs show a loop of 301 redirects to the same URLs. After resubmitting 'Permalink Settings', the page works again for a short time only.

    Could this be related with the latest update?

    http://wordpress.org/extend/plugins/wp-no-tag-base/

  2. Markus Stefanko
    Member
    Posted 2 years ago #

    I traced it down to at least the no_tag_base_request function. When I commented out status_header(301); I suddenly got 302 redirects and vice versa.

    function no_tag_base_request($query_vars) {
            //var_dump($query_vars); // For Debugging
        //backwards compatibility for older WP versions
            if(isset($query_vars['tag_redirect'])) {
            $tag =  user_trailingslashit($query_vars['tag_redirect'], 'post_tag');
            $taglink = trailingslashit(get_option( 'home' )) . $tag;
            status_header(301);
                    header("Location: $taglink");
                    exit();
            }
            return $query_vars;
    }
  3. Markus Stefanko
    Member
    Posted 2 years ago #

    Hm, I can't pinpoint it yet to this plugin or any other. It simply appeared just recently and it appears so far very sporadically.

    $wp_rewrite->flush_rules(); seems to solve it temporarily, until it starts again. Basically no canonical URLs seem to work until the rules have been flushed; and every link just shows the front page. ?p=XXX links try to forward to the canonical URLs, which then again show the frontpage.

    I wonder what is destroying them.
    The 301 behaviour could be a side-effect due to tag_redirect being set.

  4. Markus Stefanko
    Member
    Posted 2 years ago #

    Interesting part is that although I have disabled the plugin, the tags are still working without the base. Although the tag base is set to 'tag' and the links also show /tag/X. They end up on a 404 page, and if you manually remove /tag/ from the URL, the tag page is being displayed.

  5. Markus Stefanko
    Member
    Posted 2 years ago #

    It could be related with an ( even deactivated ) simple tags plugin. I have now deleted it, and am looking for the bug to reappear again.

    It's very interesting how persistent tag plugins are, even if they are deactivated.

  6. Markus Stefanko
    Member
    Posted 2 years ago #

    I have used this file to debug the issue. https://gist.github.com/2321074

    permalink structure
    '/%year%/%monthnum%/%postname%/'
    
    page permastruct
    '%pagename%'
    
    matched rule and query
    '(.+)$'
    
    matched query
    'tag_redirect=2012%2F07%2Fmy-post'
    
    request
    '2012/07/my-post'

    From the printout of the rules it seems that '(.+)$' => 'index.php?tag_redirect=$matches[1]' comes before the category rewrites. It's induced in the middle of the rewriterules, so it matches before anything else can match.

  7. Markus Stefanko
    Member
    Posted 2 years ago #

    so possibly instead of replacing a match all rule $old_base = str_replace( '%post_tag%', '(.+)', $old_base ); the (.+) rule should be added to the bottom of the rewrite rules?

  8. Markus Stefanko
    Member
    Posted 2 years ago #

    I removed the old tag base redirect support for now.

    //global $wp_rewrite;
    //$old_base = $wp_rewrite->get_tag_permastruct();
    //$old_base = str_replace( '%post_tag%', '(.+)', $old_base );
    //$old_base = trim($old_base, '/');
    //$tag_rewrite[$old_base.'$'] = 'index.php?tag_redirect=$matches[1]';

    Let's see if it keeps working. Can you confirm for when this would be necessary?

  9. Devin Walker
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Disagree - Are you by chance using the "No Category Parent" plugin alongside WP-No-Tag-Base?

    http://wordpress.org/extend/plugins/no-category-parents/

    This plugin doesn't play nicely with the newer version of WP-No-Tag-Base. I recommend WP No Category Base plugin coupled with this one. Let me know if that's what you're using or not.

  10. Markus Stefanko
    Member
    Posted 2 years ago #

    No, not using it.

    After removing the $old_base part I have so far not had any malfunctions.

  11. Markus Stefanko
    Member
    Posted 2 years ago #

    About my previous comment that the rule was coming before any category rewrites - that was the wrong formulation.

    The tag base / (.+) rewrite came before any 2012/0*/* rewrites. So whenever I would enter a post, it would instead trigger the (.+) rewrite.

    That is due to the original tag_base rewrite being in the middle of the rewrite rules. I suppose if it would be in the bottom, instead of the middle, this issue wouldn't come up, as it would only get triggered if no other rewrite rule would match.

  12. Devin Walker
    Member
    Plugin Author

    Posted 2 years ago #

    Hmm so commenting out the old tag base redirect support fixed it for you? What version of WP are you running? I'm going to mark this as resolved.

  13. luissalvador
    Member
    Posted 2 years ago #

    I have the same problem.

    When I change a tag (create a new or delete old one), I begin to have problems with redirects.

    Possible related with that I have the following plugins installed:

    WP-No-Tag-Base
    WP No Category Base - WPML compatible
    Dean's Permalinks Migration

  14. nexusbroadcast
    Member
    Posted 2 years ago #

    I was having some odd problems where the permalinks wouldnt work on some articles and even some plugins. I am using the latest version 1.2.2. I would have to go save the permalink settings and they would work again. I am using the WP No Category Base - WPML compatible plugin and I have tried the WP No Category Base plugin from the other author with the same issues. I commented out lines 74 - 78 for old tag base support. So far no more errors. I am also watching this to see if this fixes the issue. So far it seems to resolved the issue with no side effects. Could you explain a bit what these lines are for?

  15. Terrorelfe
    Member
    Posted 2 years ago #

    Same problem, same plugin, this one, it sucks.

    When I de- and activate the plugin, the loop is gone, but then suddenly, the problem appears again and again and again.

  16. Terrorelfe
    Member
    Posted 2 years ago #

    What does "resolved" stand for - I still got that problem, nothing "resolved" here.

  17. nexusbroadcast
    Member
    Posted 2 years ago #

    Terrorelfe - make those edits to the plugin and it functions properly. As far as I am concerned it is resolved - the plugin just needs to be updated now. Its a simple edit to fix what you have for now. I am sure the author will make these changes in the next release. Please consider how much you are paying for the software and understand why fixes aren't released immediately. This is a labor of love for the author, not an attempt to make money. The solution was posted, so lets give the guy a little credit and breathing room. Thanks for the great plugin!

    //global $wp_rewrite;
    //$old_base = $wp_rewrite->get_tag_permastruct();
    //$old_base = str_replace( '%post_tag%', '(.+)', $old_base );
    //$old_base = trim($old_base, '/');
    //$tag_rewrite[$old_base.'$'] = 'index.php?tag_redirect=$matches[1]';
  18. Devin Walker
    Member
    Plugin Author

    Posted 2 years ago #

    I've released a new update (v1.2.3) to WP-No-Tag-Base that fixes the issue many sites were experiencing with redirect errors and old tag bases not 301 redirecting. Remember to clear your DNS cache while and to refresh your WP permalinks manually (settings > permalinks) while debugging. If you have anymore issues please jump over to my site and use the comments form or contact me so we can work through them!

    @nextusbroadcast - Thanks for the kind words. You hit the nail on the head, it's a labor of love.

  19. Terrorelfe
    Member
    Posted 2 years ago #

    Thanks Devin.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic