Faq How can i rewrite a dynamic xml sitemap url to 'sitemap.xml'?
How can i rewrite a dynamic xml sitemap url to 'sitemap.xml'?

Although this is something useless and without any advantage, you may want to rewrite sitemap links using aliases. To do this you must use the htaccess to rewrite a sitemap link using an alias such as 'sitemap.xml', indeed all sitemap URLs are normally dynamic and no more based on static files. The easiest way to accomplish this, is adding a rule to your htaccess file like the following one:

RewriteRule ^sitemap\.xml$ index.php?option=com_jmap&view=sitemap&format=xml [L]


You can rewrite even multiple sitemap formats, for example mobile, video, images, etc:

RewriteRule ^sitemap_mobile\.xml$ index.php?option=com_jmap&view=sitemap&format=mobile [L]


RewriteRule ^sitemap_images\.xml$ index.php?option=com_jmap&view=sitemap&format=images [L]


RewriteRule ^sitemap_videos\.xml$ index.php?option=com_jmap&view=sitemap&format=videos[L]


This is also explained in more details in the pdf docs at the paragraph 'Having dummy sitemap.xml file'.



Take care to the location used to add the rule to your htaccess file. In some cases placing the new rule for the sitemap after other already present rewriting rules could not work. In such case place the new rule before them, for example just after the initial 'RewriteEngine On' rule.



Notice that if your Joomla website is multilanguage you have to specify the language part in the htaccess rule as well, for example for the English language the htaccess rule will be as the following:

RewriteRule ^en/sitemap\.xml$ index.php?option=com_jmap&view=sitemap&format=xml&lang=en [L]



Obviously you can even choose to manage a physical static file named sitemap.xml at the server root. With JSitemap you can export various sitemap XML files so it's possible to rename them as you prefer and upload them to the desired server path through FTP.