Do robots.txt and sitemap.xml need to be physical files?

by ag16920   Last Updated February 22, 2018 18:04 PM

I have both setup in my routes:

Route::get('/robots.txt', function() {
    // robots.txt contents here

Route::get('/sitemap.xml', function() {
    // sitemap.xml contents here

I can access them perfectly through the browser but I'm getting a message from Google Search Console that they are not detected. Do they need to be physical files in the root folder so they can be detected?

Related Questions

Updated January 26, 2018 17:04 PM

Updated May 21, 2019 06:04 AM

Updated April 17, 2017 13:04 PM

Updated February 28, 2019 23:04 PM