WordPress.org

Make WordPress Core

#43311 closed defect (bug) (worksforme)

Missing full path to Sitemap in virtual robots.txt

Reported by: kohlermedia Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:
PR Number:

Description (last modified by ocean90)

The function witch generates the virtual robots.txt strips the path https://mydomain.com/sitemap.xml to /sitemap.xml.

Tested with

<?php
add_filter( 'robots_txt', 'robots_mod', 10, 2 );
function robots_mod( $output, $public ) {
        $output .= "Sitemap: https://mydomain.com/sitemap.xml/\n";
        return $output;
}

in functions.php

sitemaps.org notes
"You can specify the location of the Sitemap using a robots.txt file. To do this, simply add the following line including the full URL to the sitemap: Sitemap: http://www.example.com/sitemap.xml"

Google search console marks a sitemap without full path as error.

Attachments (1)

2018-02-14 09_52_41-Search Console - robots.txt-Tester.png (5.9 KB) - added by kohlermedia 20 months ago.
Printscreen of google search console robots.txt tester

Download all attachments as: .zip

Change History (2)

@kohlermedia
20 months ago

Printscreen of google search console robots.txt tester

#1 @ocean90
20 months ago

  • Description modified (diff)
  • Focuses coding-standards removed
  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed
  • Version 4.9.4 deleted

Hello @kohlermedia, welcome to WordPress Trac!

Thanks for your report. I couldn't reproduce the issue on a clean install. In core we have no function that would replace the domain there.

Try disabling all plugins and maybe activate a default theme to find the cause for this. For additional help, please try our Support Forums.

Note: See TracTickets for help on using tickets.