Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 使用Joomla和Xmap重写sitemap.xml的URL_Apache_Mod Rewrite_Joomla_Sitemap - Fatal编程技术网

Apache 使用Joomla和Xmap重写sitemap.xml的URL

Apache 使用Joomla和Xmap重写sitemap.xml的URL,apache,mod-rewrite,joomla,sitemap,Apache,Mod Rewrite,Joomla,Sitemap,我正在使用Xmap为我的Joomla网站创建一个XML站点地图。我可以通过进入index.php?option=com\uxmap&view=xml&tmpl=component&id=1访问站点地图 我想改用Apache的URL重写,通过“sitemap.xml”实现这一点,因此我尝试在.htaccess中使用以下代码: RewriteEngine On RewriteRule ^sitemap\.xml$ index.php?option=com_xmap&view=xml&

我正在使用Xmap为我的Joomla网站创建一个XML站点地图。我可以通过进入index.php?option=com\uxmap&view=xml&tmpl=component&id=1访问站点地图

我想改用Apache的URL重写,通过“sitemap.xml”实现这一点,因此我尝试在.htaccess中使用以下代码:

RewriteEngine On
RewriteRule ^sitemap\.xml$ index.php?option=com_xmap&view=xml&tmpl=component&id=1 [L]
但是,这给了我一条错误消息:

错误500-找不到视图[名称、类型、前缀]:xml、xml、xmapView

我需要做什么才能让它工作


(如果有区别,则站点是从子目录运行的,而不是从域的根目录运行)

您忘记了QSA标记:

RewriteEngine On
RewriteRule ^sitemap\.xml$ index.php?option=com_xmap&view=xml&tmpl=component&id=1 [QSA,L]

您忘记了QSA标记:

RewriteEngine On
RewriteRule ^sitemap\.xml$ index.php?option=com_xmap&view=xml&tmpl=component&id=1 [QSA,L]

我猜您在Joomla全局配置中使用的是向URL添加后缀。如果是这种情况,请将以下代码添加到
.htaccess
文件中:

RewriteCond %{REQUEST_URI} ^/sitemap.xml

RewriteRule .* /index.php?option=com_xmap&id=1&view=xml&format=html [L]

我猜您在Joomla全局配置中使用的是向URL添加后缀。如果是这种情况,请将以下代码添加到
.htaccess
文件中:

RewriteCond %{REQUEST_URI} ^/sitemap.xml

RewriteRule .* /index.php?option=com_xmap&id=1&view=xml&format=html [L]

作为记录,在不使用重写的情况下实现相同结果的另一种方法是在站点的根目录中创建一个sitemap.xml文件,其中包含以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
  <loc>http://www.domain.com/index.php?option=com_xmap&amp;view=xml&amp;tmpl=component&amp;id=1</loc>
</sitemap>

</sitemapindex>

http://www.domain.com/index.php?option=com_xmap&view=xml&;tmpl=组件和;id=1
行中的具体内容因站点而异,请从后端>组件>Xmap>XML站点地图链接获取它


祝你好运

对于记录,另一种不使用重写来实现相同结果的方法是在站点的根目录中创建一个sitemap.xml文件,其中包含以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
  <loc>http://www.domain.com/index.php?option=com_xmap&amp;view=xml&amp;tmpl=component&amp;id=1</loc>
</sitemap>

</sitemapindex>

http://www.domain.com/index.php?option=com_xmap&view=xml&;tmpl=组件和;id=1
行中的具体内容因站点而异,请从后端>组件>Xmap>XML站点地图链接获取它


祝你好运

我添加了QSA,但没什么区别。我添加了QSA,但没什么区别。谢谢David,我从来不知道站点地图索引。如果有人想了解更多信息,sitemaps.org会提供详细信息。谢谢大卫,我从来不知道sitemap索引。如果有人想了解更多信息,sitemaps.org会提供详细信息。