0

I've been looking for an easy way to point search engines to the sitemap.xml file in the root of the website. I've been using Google Sitemap Lite in combination with Navee or Structure. And it's generating sitemap.xml output like a charm.

But I've put the code in a template group named "sitemap". So I need to edit the .htaccess file, so the /sitemap.xml url points to /index.php?/sitemap. I couldn't get it to work...

2

There is an easier approach to this!

In the template group, the one that contains the template that is used for the homepage of your site, I've added an xml template and named it "sitemap.xml". The actual template filename becomes sitemap.xml.xml, and added the template code to generate the sitemap.xml structure.

This in combination with the standard .htaccess file for "nice urls" (see below), browsing to /sitemap.xml renders the sitemap.xml template I've just made.

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]

This is not a great invention, but it could save some people some time.

3
  • I guess you need to disable strict_urls for this to work. Am I right? – Sobral May 17 '13 at 17:03
  • Yes, indeed. I forgot to mention that. – Diederik May 19 '13 at 12:54
  • 1
    So, why not to keep everything together? Instead of to use mod_rewrite, to disable the strict_urls and to name a file on a tricky way, you can use just the mod_rewrite and point right to "index.php/template_group/sitemap". – Sobral May 19 '13 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.