【问题标题】:create a sub url in sitemap在站点地图中创建子 url
【发布时间】:2012-04-07 04:47:30
【问题描述】:

我正在尝试为我的网站构建站点地图。到目前为止,我已经成功构建了它。

现在我注意到我有一些与其他 url 相关的 url。它们包含我网站 90% 的网址。

例如我有这个网址:

www.mysite.com/mainurl

以及与上述网址相关的网址:

www.mysite.com/mainurl/mypage1
www.mysite.com/mainurl/mypage2
www.mysite.com/mainurl/mypage3

我想知道是否有办法将第二个网址关联到第一个网址,例如子网址。

我还有一个问题,我应该使用哪种类型的 url 格式?

此类型:www.mysite.com/mainurl 或此类型:www.mysite.com/page.php?url=mypage1

【问题讨论】:

  • 您应该使用第一个网址。它与 seo 相关...

标签: php url sitemap


【解决方案1】:

或许可以考虑使用PHP的explode函数来分割url,然后循环比较值,类似:

$items = get_your_array();

foreach($items as $item)
{
    $urlParts = explode...
    foreach($urlParts as $part => $val)
    {
        // Organise parts into an associative array, so you can loop over it later
        // This would produce something that also could be accessed like...
        // $items['www.mysite.com']['mainurl']['mypage1'];
        // $items['www.mysite.com']['mainurl']['mypage2'];
        // Having the array key the same as the value as it would probably filter out duplicates, so you need to consider that
    }
}

至于你的第二个问题,使用第一种 URL 样式,它们更适合 SEO。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-30
    • 1970-01-01
    • 1970-01-01
    • 2014-02-11
    • 2011-08-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多