【问题标题】:Generating sitemap.xml on multi stores在多个商店生成 sitemap.xml
【发布时间】:2011-08-18 11:02:30
【问题描述】:

我在一个 Magento 安装上设置了多商店,所有商店都在不同的服务器上。我为它们中的每一个都创建了符号链接。 现在我想为每个商店生成 sitemap.xml。我在我的根目录中创建了一个名为站点地图的文件夹,在站点地图中我为每个商店创建了文件夹。 (即站点地图内的 store1、store2)。现在,我在每个商店的文件夹中生成 sitemap.xml。我还在 store1.com 的 .htaccess 中添加了以下行:

RewriteRule ^sitemap.xml$ @987654321@ [NC]

(在此处找到此帮助:http://www.magentocommerce.com/boards/viewthread/59388/) 现在,如果我输入 www.store1.com/sitemap.xml,我应该能够看到该商店的 xml,但我收到 404 Not Found 错误。 有什么想法吗?

【问题讨论】:

  • 并且您的文件已生成并且符号链接有效?你可以从它们的绝对网址访问文件?
  • 是的,sitemap.xml 正在生成并且系统链接有效。我也可以通过键入 www.mainserver.com/sitemaps/store1/sitemap.xml 来访问这些文件。就在我输入 www.store1.com/sitemap.xml 时,我得到了这个错误。
  • 如果您可以直接访问它们,那么您的重写规则是错误的

标签: magento sitemap.xml


【解决方案1】:

复制自Magento stack

注意:我尝试过这种方式,它总是有效的。

首先,在您网站的根目录中创建一个名为 sitemaps 的新文件夹,然后为每个域创建子文件夹。

/sitemaps/domain_1/
/sitemaps/domain_2/

然后登录到 Magento 管理员并导航到 - catatlog -> google sitemap

为每个商店创建或编辑站点地图列表,并将“站点地图路径”字段设置为您为商店创建的路径。

/sitemaps/domain_1/
/sitemaps/domain_2/

更新您的 robots.txt 文件。确保搜索引擎蜘蛛正确定向到新站点地图。您可能需要更新或创建 robots.txt 文件。编辑 robots.txt 文件并在顶部添加以下行 —

# Website Sitemap
Sitemap: http://www.domain_1.com/sitemaps/domain_1/sitemap.xml  
Sitemap: http://www.domain_2.com/sitemaps/domain_2/sitemap.xml

最后,如果您的网站使用 Apache 网络服务器引擎,您应该更新网站根目录中的 .htaccess 文件,以将任何其他站点地图请求定向到正确的位置。 在读取的行下方找到以下行 - RewriteEngine on

并在其下方添加以下重定向语句-

# Sitemap: http://www.domain_1.com/sitemaps/domain_1/sitemap.xml
RewriteCond %{HTTP_HOST} ^.*domain_1\.com$
RewriteRule ^sitemap.xml$ sitemaps/domain_1/sitemap.xml [NC,L,R=301]

# Sitemap: http://www.domain_2.com/sitemaps/domain_2/sitemap.xml
RewriteCond %{HTTP_HOST} ^.*domain_2\.com$
RewriteRule ^sitemap.xml$ sitemaps/domain_2/sitemap.xml [NC,L,R=301]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多