PHP:将站点地图.xml移动到文件夹中


php: move the sitemap.xml into folder

有一个网站具有由.htaccess文件存档的多语言功能。

我已经生成了sitemap.xml文件,我可以使用sitename.com/sitemap.xml访问它

在 php 方面有一点经验,我会问如何将.xml文件"移动"到一个地方,以便我可以通过 sitename.com/ro/sitemap.xml 访问它?

您可以将sitemap.xml保存在根文件夹中,然后将此规则添加到DocumentRoot.htaccess中:

RewriteEngine On
RewriteBase /
RewriteRule ^ro/(sitemap'.xml)$ /$1 [L,NC]

现在,您可以将此 URL 用作http://sitename.com/ro/sitemap.xml