I've attempted to add an xml sitemap within the /public directory but received a 404 because htaccess is blocking the document. What is the proper location and method to add an xml sitemap to Craft?

  • What is a "wow"?
    – Anna_MediaGirl
    Feb 28 '15 at 1:57
  • Sorry I meant 404 Feb 28 '15 at 3:38
  • 2
    Please add more information to your question... How did you confirmed it was htaccess blocking the xml file load? What are the contents of your htaccess file? What part of the htaccess code is causing the 404?
    – Anna_MediaGirl
    Feb 28 '15 at 4:28

The default '.htaccess' file that comes with craft should not 'block' or redirect any files that exist; it simply routes what would otherwise be 404 requests (i.e. documents that don't exist) to craft, so that craft can attempt to resolve the route.

If your sitemap is a static file, then the correct location would be in your public folder. If you are receiving an error trying to access it, then something else is going on with your site (possibly from a modified '.htaccess' file, or apache configuration).

If generating your sitemap dynamically via a craft twig template or plugin, then your sitemap template would likely be in your templates folder. If you are receiving a 404 response then the route to the sitemap has not been properly configured in craft (in your section, plugin, or routes settings depending on how you are defining it).

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.