开发者

Url is returned with 404 error, but content exists

开发者 https://www.devze.com 2023-03-14 09:35 出处:网络
So, I would like to get url \"http://example.com/sitemap.xml\". Content(xml) was returned and shown in browser. But in firebug I saw that status code of this url - 404. So, when I had posted this url

So, I would like to get url "http://example.com/sitemap.xml". Content(xml) was returned and shown in browser. But in firebug I saw that status code of this url - 404. So, when I had posted this url to google webmaster they said "General HTTP error: 404 not found".

I can not understand how it could happen - In browser I see a valid xml, but thi开发者_C百科s url return 404 error.

Server settings?

p.s. sitemap.xml is not a file. Content is generating using php.


Based on our conversation in question's comments:

1) Specify 200 code explicitly on the very top of your code: header("HTTP/1.0 200 OK", true);

2) Based on your .htaccess I think that the request for sitemap.xml is not handled directly to index.php, instead it goes via 404 handler first. I would suggest to have explicit rewrite rule for sitemap.xml to be redirected to index.php (preferably to a dedicated script (e.g. sitemap.php) to exclude whatever complications index.php may unintentionally introduce).

0

精彩评论

暂无评论...
验证码 换一张
取 消