Thursday, 28 August 2014 13:23

beggarly

Xmap sitemap as sitemap.xml

1 1 1 1 1 1 1 1 1 1 Rating 77% (17 Votes)

Xmap generates the sitemap dynamically every time the sitemap is visited so it can always provide a really up to date list of links. That's the reason why there is no such sitemap.xml file. But there is a workaround for this using your .htaccess file.

Add the following lines to your .htaccess file:

RewriteCond %{REQUEST_URI} ^/sitemap.xml
RewriteRule .* /index.php?option=com_xmap&id=1&view=xml

After that, you can visit your XML sitemap using a URL like this:

http://www.example.com/sitemap.xml

 

Multilingual sites

If you have a multilingual site you can create as many aliases as you want. For example:

# English sitemap
RewriteCond %{REQUEST_URI} ^/sitemap-en.xml
RewriteRule .* /index.php?option=com_xmap&id=1&view=xml&lang=en
# Spanish sitemap
RewriteCond %{REQUEST_URI} ^/sitemap-es.xml
RewriteRule .* /index.php?option=com_xmap&id=1&view=xml&lang=es

If you are using SEF urls and yout site redirects the user to a specific prefix in the url, you will need to add those in your rules too, like this:

# English sitemap
RewriteCond %{REQUEST_URI} ^/en/sitemap.xml
RewriteRule .* /index.php?option=com_xmap&id=1&view=xml&lang=en
# Spanish sitemap
RewriteCond %{REQUEST_URI} ^/es/sitemap.xml
RewriteRule .* /index.php?option=com_xmap&id=1&view=xml&lang=es

 

Sitemap index

Another option is to create a sitemap index in your site's root folder. Just create a file called sitemap.xml in your site with the following content:

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

You can add as many "sitemap" sections as you want (but not more than 50,000). Just remember to update the urls with correct sitemap id and language codes, or remove the &lang=xx if not needed.