【发布时间】:2021-06-01 22:55:36
【问题描述】:
我在本地主机上的 magento2 中生成了一个 sitemap.xml 文件。以下是链接http://magento.local/sitemap.xml 现在我想使用 URL 重写将上面的 URL 重定向到 http://magento.local/pub/sitemap.xml。我已将 URL 重写创建为 shown in this image
但是http://magento.local/sitemap.xml URL 没有被重定向http://magento.local/pub/sitemap.xml。但是如果我删除原始的 sitemap.xml 文件,它会被重定向到新的 URL。有什么方法可以在不删除现有 sitemap.xml 的情况下重定向它?
另一种选择 我将以下规则添加到 .htaccess 文件中,它在本地运行良好,但在服务器上却失败了。 URL 没有被重定向
<IfModule mod_alias.c>
Redirect 301 /sitemap.xml http://magento.local/pub/sitemap.xml
</IfModule>
【问题讨论】:
-
我在 .htaccess 文件中添加了以下规则,它在本地工作正常,但在服务器上它不起作用
Redirect 301 /sitemap.xml magento.local/pub/sitemap.xml