大网数据广告活动
网站运营与故障问答

Where can I put my sitemap in my directory structure under Laravel? It is 404 in the directory root

· 52CE 我爱测

I'm trying to submit my sitemap on my Google console but every time I add it, it keeps saying it couldn't fetch, I have uploaded my sitemap.xml into my domain root directory but still Google is not seeing it. Please, how can I so…

问题原文

原帖链接 · kratosserver2008 · CC BY-SA 4.0

I'm trying to submit my sitemap on my Google console but every time I add it, it keeps saying it couldn't fetch, I have uploaded my sitemap.xml into my domain root directory but still Google is not seeing it. Please, how can I solve this issue, have been on this for the past two days and it's like I'm going in circles.

My sitemap is in the public_html folder with name sitemap.xml.

UPDATE#1: This is my directory structure:

/home/winnerrs
    /public_html
        /app
        /bootstrap
        /config
        /database
        /docker
        /public
        /resources
        /routes
        /storage
        .htaccess
        artisan
        composer.json
        composer.lock
        docker-compose.yml
        Dockerfile
        package.json
        phpunit.xml
        README.md
        readme.md
        robots.txt
        server.php
        sitemap.xml
        webpack.mix.js

UPDATE#2: This my .htaccess file in the document root:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^$ public/ [L]
    RewriteRule (.*) public/$1 [L]
</IfModule>

已采纳解答

原帖链接 · MrWhite · CC BY-SA 4.0

Having looked at your directory structure, it would seem that many (all?) files in the document root (where you have uploaded sitemap.xml) are not accessible - they all return 404 Not Found when accessed publicly.

It looks like this might be a Laravel app and you are perhaps rewriting everything to the /public subdirectory (a typical usage pattern with Laravel). In which case you should move sitemap.xml (and any other files that should be publicly accessible) to the /public subdirectory.

To confirm this, we would need to see the contents of your root .htaccess file. (Please edit your question to include this.)

UPDATE: Your .htaccess file confirms the above.

RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]

From your .htaccess file in the document root we can see that all requests are rewritten to the /public subdirectory. So, a request for example.com/sitemap.xml is internally rewritten to example.com/public/sitemap.xml.

This means your document root is "effectively" /home/winnerrs/public_html/public, not /home/winnerrs/public_html, as you first thought.

You need to move the sitemap.xml file from the public_html directory to the public_html/public directory.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2018-12-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。