• Resolved djwilko12

    (@djwilko12)


    Hello,
    On GSC’s Breadcrumbs report i saw 2 errors:
    1- Either “name” or “item.name” should be specified
    2- Missing field “id”
    When i clicked to see which URL’s are generating those errors i saw it was from a URL we never created… and for some reason WordPress creates them…
    Its like this: https://www.domainname.com/?p=t
    I checked other wordpress sites adding /?p=t at the end of the URL and it seems to be generalized on WordPress. How to deal with it? How to add ¨no index¨? Or maybe you have better suggestion.
    On the other hand, what i dont understand is how GSC has recognized those urls… we never used them at all… in fact, we knew they existed after checking this Breadcrumbs report.
    Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi @djwilko12,

    We can understand that invalid URLs like this one can be a frustrating problem. WordPress appears to do a search or make a “best guess” on what page to display in these cases.

    Unfortunately, We’re not able to shed any further light on how Google found these links with “?p=t” or why it crawled them.

    Since this doesn’t appear to be caused by Yoast SEO or appear to be a valid URL, it may help to prevent the URL from being crawled and indexed.

    If this is more than an isolated problem or appears in search results for your site, you may try to set only these pages to noindex by add custom code (See Yoast SEO wpseo_robots filter).

    As an alternative, you could try other methods like using the X-Robots-Tag header.

    Hope this helps!

    Hi @djwilko12,

    We had a similar problem. We solved it by performing the following:

    (1) Temporarily block your URL (https://www.domainname.com/?p=t) using the Google Removal Tools provided here.

    (2) Add the following snippet to your functions.php file:

    if (isset($_GET['cat']) && $_GET['p'] == t) {
          status_header(404);
          include( get_404_template() );
          exit;
    }

    Notes:

    (a) We recommend using the plugin, Code Snippets, to accomplish Step (2) above. The above snippet will tell Google that your URL is “non-existent” (i.e., via 404 message) and stop indexing it.

    (b) For more information on the above snippet, click here.

    (3) Clear all cache (back-end and front-end).

    (4) Ask Google to re-crawl your website (use your sitemap URLs).

    Important: The above will not produce “instant” results. You will need to wait 2-4 weeks before you see the change(s) take effect. Google bot crawlers are not too fast.

    Hope the above helps.

    Thread Starter djwilko12

    (@djwilko12)

    Thank you very much @jetxpert for your help. That code you provided, what does it do exactly?
    Regards!

    Plugin Support devnihil

    (@devnihil)

    @djwilko12 The code snippet that @jetxpert provided will return a 404 status for the https://www.domainname.com/?p=t URL.

    @djwilko12,

    @devnihil’s statement is correct. Essentially, the 404 status tells Google not to index that page.

    Correction: Apologies. Use the snippet below instead (cat replaced with p)

    if (isset($_GET['p']) && $_GET['p'] == t) {
          status_header(404);
          include( get_404_template() );
          exit;
    }

    Cheers!

    Thread Starter djwilko12

    (@djwilko12)

    Thank you! I tried. But when i go to the https://www.domainname.com/?p=t

    Warning: Use of undefined constant t – assumed ‘t’ (this will throw an Error in a future version of PHP) in /home/customer/www/domainname.com/public_html/wp-content/themes/flatsome-child/functions.php on line 3

    i changed the real domain with “domainname”

    @djwilko12,

    Optional solutions:

    (1) Try variations of the above snippet until you get a 404 return status. Double check your Code Snippets settings (if using this plugin).

    (2) Add the following to your robots.txt file:

    User-agent:*
    Disallow: /?p=t

    (3) Add the following rule to your htaccess file:

    RedirectMatch 404 "/?p=*"

    or

    RedirectMatch 404 "/?p=t"

    or

    RedirectMatch 404 "/?p*"

    (4) Go to WP Dashboard > Settings > Permalinks and click “Save Changes” (this may help rebuild and fix your website’s permalink structure)

    Beyond the above, Yoast SEO will need to give you a hand.

    Cheers!

    Plugin Support devnihil

    (@devnihil)

    @djwilko12 Instead of placing the code within your theme’s functions.php file, have you tried using the Code Snippets plugin instead? I wasn’t able to replicate the error you are receiving so it may be related to it’s placement within your functions.php file.

    I tested the code that @jetxpert provided and it did return a 404 page for the /?p=-1 URL, as expected.

    Unfortunately we can’t offer support on custom code. Since we don’t want to take the risk that we break your website by suggesting incorrect or incomplete code, we cannot advise you on how to make such changes. Thank you for your understanding.

    Thread Starter djwilko12

    (@djwilko12)

    ok, thank you very much

    Plugin Support devnihil

    (@devnihil)

    @djwilko12 You’re welcome. We are going ahead and marking this issue as resolved but please let us know if you require any further assistance.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Issue with “/?p=t” at the end of the URL’ is closed to new replies.