Support » Fixing WordPress » 404 tag errors on Google Search Console

  • Resolved worldless

    (@worldless)


    I could barely find the same problem that’s close to mine in stackoverflow but unfortunately there were no answers !!: Tag pages are causing Crawl Errors (Not found) for Doubleclick Ads

    The thing is I recently received many 404 errors regarding tags. all of them contain two tags coming after each other linking from http://website.com/tag/mytag/feed/ like the following:

    website.com/tag/my-tag-1/my-tag-2

    (I had my feed disabled by WP Hide Security Enhancer. but I’m not sure if this is the reason why)

    On the other side I have some internal links in my posts as well that are some sort of connected to the issue. I used the following piece of code for my internal links:

    <a href="../myslug/" rel="noopener" target="_blank">my des text here</a>

    I replaced my web link with ../ because I thought that I might change the domain name some day so that I didn’t have to replace them. I believe that’s why I’m seeing such issues because every tag is sort of related to those pages having these internal links and since I stopped using ../ for my new posts I didn’t come up with any errors!

    This may have something to do with Yoast sitemap as well because I guess it all started when I set the sitemap and put the links in my robot.txt like this :

    User-agent: *
    
    Allow: /wp-content/uploads/
    Allow: /wp-admin/admin-ajax.php
    
    Disallow: /readme.html
    Disallow: /wp-admin/
    Disallow: /wp-content/plugins/
    Disallow: /refer/
    
    Sitemap: http://website.com/post-sitemap.xml
    Sitemap: http://website.com/page-sitemap.xml
    Sitemap: http://website.com/category-sitemap.xml
    Sitemap: http://website.com/post_tag-sitemap.xml

    Can someone please explain to me why this is happening and how to fix it ?!! I got no single idea how to fix this. should I replace ../ with my web address and redirect them one by one using a Redirection plugin ?!! but the problem is I have no idea which tag is related to my issue not to mention that I’m not sure enough that those internal links are the cause of the issue.

    or maybe I should redirect the all to my home page using this in my theme 404.php file :

    <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: ".get_bloginfo('url'));
    exit();
    ?>

    Any idea on this would be helpful.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi there,

    In my research I’ve found that the 404 error is primarily a client side error, and so would most likely have to do with the ../ URL.

    Here’s a good resource I found for troubleshooting.

    Hope this helps!

    -Marcus

    Thanks Marcus

    Unfortunately it couldn’t help. the thing is I almost (and I mean almost) know where the problem lies but I have no idea how to redirect them now that the google search console has run into errors. like I said tags are working fine separately. they’re only mixed up with each other. if I delete one, the other works just fine. even if I fixed the ../ url it wouln’t fix the issue.

    You know I’d like to redirect all 404 errors using the following code :

    <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: ".get_bloginfo('url'));
    exit();
    ?>

    but not to the home page and not to a 404 custom page as well. when I type any gibberish after my website (say http://www.example.com/asdasd) it redirects to a default 404 error page with some info and a search bar. how may I modify it so that it redirects to the default WordPress 404 error ?!!

    architekco

    (@architekco)

    First and foremost: None of what I am about to say is meant to be rude. I am just trying to help anyone who may come across this topic in the future.

    Now then – I’m not sure what you did to resolve your issue, but to future readers, do not do anything that you read/see above. I can hardly make sense of the logic used.

    I replaced my web link with ../ because I thought that...

    Stop right there.

    1. A good rule of thumb is, if you dont actually know what something does, dont implement it. WordPress could not possibly make it easier to create an inline link. Select your text, click the “link” button in the editor, and select your destination page. Then, if you change your domain in the future, WordPress handles the internal linking switcheroo on its own. Dont use ./ or ../. See here for more clarification https://stackoverflow.com/questions/7591240/what-does-dot-slash-refer-to-in-terms-of-an-html-file-path-location

    2. These days, the use of target=”_blank” is generally frowned upon due to security concerns and poor UX. Don’t use it, and especially dont use it for internal linking.

    may have something to do with Yoast sitemap as well because I guess it all started when I set the sitemap and put the links in my robot.txt

    3. The correct file is robots.txt – not robot.txt. Even if you put it in a robot.txt, WordPress automagically creates and serves a basic robots.txt when it detects a request for one when one does not currently exist.

    4. Dropping all of those sitemap links in your robots.txt file is entirely redundant, as /sitemap_index.xml contains all of the sub-sitemaps already. Unless you have specific reasons to change your robots.txt, and you know what the implications are, your robots.txt file should really contain nothing more than:

    User-agent: *
    Disallow: /wp-admin/
    Allow: /wp-admin/admin-ajax.php

    5. Dont:
    or maybe I should redirect the all to my home page using this in my theme 404.php file...

    A 404 error means that a bot could not find a file at the linked destination. So, in order to do what you said you wanted to do (the redirect), you would have to manually create all of the non-existent files. Which, would then actually make the 404 error go away because now the file would exist. But then you would direct the crawler back to the homepage with a header that said the file in fact now did NOT exist…… What a nightmare.

    When your server detects a request for a file that does not exist, the server will serve your 404 page in place of the missing file. A 404 error and a 404 page are two entirely different things.

    I could go on but I’ll just end with this – do not edit your theme files. Create a child theme instead. It is so simple to do https://codex.wordpress.org/Child_Themes (or at least simpler than fixing all of the issues you will cause by editing your theme files directly).

    worldless

    (@worldless)

    You don’t sound rude at all ! the reason why I opened this topic (or we all open topics) was (is) to learn more and you’re helping with this process. it’s totally normal and nothing to worry about.

    To fix the issue all I did was replace ../ with the actual web link.

    1. like I said there was a reason why I did it and I had no idea WordPress would handle the internal linking that way! now that I know how it works, I won’t make the same mistake anymore.

    2. According to the Good Reasons and Bad Reasons of css-tricks.com I couldn’t find any security or vulnerability issues however as explained here any vulnerability issue can be fixed using rel="noopener" or rel="noopener noreferrer" attribute. even wordpress.org uses these two attributes (rel=”noopener” & target=”_blank”)

    3. Yea there was a typo. I meant robots.txt

    4. How to Optimize Your WordPress robots.txt for SEO

    5. I knew what 404 error meant but I was facing a weird issue (too many 404 errors and all of them with links having two tags next to each other !!). I had never seen such a thing before. there were many plugins that could use to redirect them to a new location easily but like I said I had no idea where to redirect them (tag/tag-1 or tag/tag-2 ?!!) !! that’s why I was gonna redirect them all to homepage once and for all. it’s been three months since then and now that all those ../s have been replaced with the actual web link, the problem seems to have been rectified.

    6. there’s something wrong with child themes. I know you can edit any file if you use the same file name (say example.php) but unfortunately you can’t edit files inside folders. even creating a folder in child-them and putting the file inside the folder won’t do anything and since I’m not a coder I stopped using child theme.

    All in all thanks for your time explaining about all those issues

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘404 tag errors on Google Search Console’ is closed to new replies.