【问题标题】:How to properly display links in multiple sitemap [closed]如何在多个站点地图中正确显示链接[关闭]
【发布时间】:2019-08-20 12:14:27
【问题描述】:

我正在生成多个站点地图文件并将站点地图索引与 Opencart 框架一起使用。

$type 是产品、类别、信息

$page 是数字

          $output .= '  <sitemap>';
          $output .= '    <loc>' .$this->url->link('feed/google_sitemap/'.$type, ($page ? 'page='.$page++ : '')).'</loc>';
          $output .= '    <lastmod>'. date('Y-m-d') .'</lastmod>';
          $output .= '  </sitemap>';

最后我得到了这样的结果(一切正常)

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>http://localhost/index.php?route=feed/google_sitemap/product&amp;page=1</loc>
<lastmod>2019-08-20</lastmod>
</sitemap>
<sitemap>
<loc>http://localhost/index.php?route=feed/google_sitemap/product&amp;page=2</loc>
 <lastmod>2019-08-20</lastmod>
</sitemap>
</sitemapindex>

链接看起来像这样重要吗?

<loc>http://localhost/index.php?route=feed/google_sitemap/product&amp;page=2</loc>

或者它们应该看起来像

<loc>http://localhost/sitemap-product-1</loc>

【问题讨论】:

    标签: php xml sitemap


    【解决方案1】:

    &lt;loc&gt; 中的位置是一个有效的 url,这一点很重要。如上所示,它会读作:

    http://localhost/index.php?route=feed/google_sitemap/product&page=2

    如果你访问这个 url,你会得到内容吗? &amp; 字符很可能应替换为 ?

    【讨论】:

    • 是的,我正在获取 page=2 的内容
    • 那没关系,站点地图是正确的。
    • 如果你的url中有一个字符?(你之前已经有route),字符&amp;不能被?替换。
    • @K. B. 对不起,我没听懂你,你是什么意思?
    • @Paul 说过“如果你访问这个 url,你会得到内容吗?很可能 & 字符应该被替换为?”,所以这不是事实。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-06
    • 1970-01-01
    • 2012-08-16
    • 2015-09-16
    • 1970-01-01
    相关资源
    最近更新 更多