【发布时间】:2020-04-09 15:27:23
【问题描述】:
我已经安装了一个新的 Laravel (v 6.7) 项目,然后安装了这个包 spatie/laravel-sitemap。因此,就像在文档中一样,我已将以下代码添加到我的路由文件 web.php 文件中
use Spatie\Sitemap\SitemapGenerator;
Route::get('/sitemap', function () {
ini_set('max_execution_time', 300); // 5 minutes
SitemapGenerator::create('http://sandrianaplantations.com/')->writeToFile('sitemap.xml');
return 'completed';
});
然后当我检查 sitemap.xml 文件时,它的内容如下
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>http://sandrianaplantations.com/</loc>
<lastmod>2019-12-17T06:35:43+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
</urlset>
但如果我通过XML-sitemap.com 为上面的 url 生成站点地图,它会生成下面的内容
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<!--
created with Free Online Sitemap Generator www.xml-sitemaps.com
-->
<url>
<loc>https://sandrianaplantations.com/</loc>
<lastmod>2019-12-17T06:33:44+00:00</lastmod>
<priority>1.00</priority>
</url>
<url>
<loc>https://sandrianaplantations.com/About-us/</loc>
<lastmod>2019-12-17T06:33:44+00:00</lastmod>
<priority>0.80</priority>
</url>
<url>
<loc>https://sandrianaplantations.com/Gallery/</loc>
<lastmod>2019-12-17T06:33:44+00:00</lastmod>
<priority>0.80</priority>
</url>
<url>
<loc>https://sandrianaplantations.com/Contacts/</loc>
<lastmod>2019-12-17T06:33:44+00:00</lastmod>
<priority>0.80</priority>
</url>
</urlset>
所以任何人都可以告诉我我是否在我的路线文件中犯了任何错误。(web.php)。我已经阅读了那里的官方文件。但是什么也找不到。也通过YouTube。也几乎检查了以下问题。
【问题讨论】:
标签: php xml laravel laravel-sitemap