I have magento 2 store and when i create a sitemap it works ok , but after that when i want to access the newly created sitemap it throw 404 error page.i'm using nginx server.

how can i fix this ??

enter image description here

3 Answers 3


Put your sitemap in the /pub/ folder:

enter image description here

Then go to http://www.domain.com/sitemap.xml


you should check the rules of nginx, the root dir of nginx is set to /pub/ but that is not the correct directory for nginx to search for the sitemaps. so you should configure a location for nginx one level under the pub (the real root dir of mage2) and there will nginx find the sitemaps. I create all sitemaps in a subdir "sitemaps". mine looks like this:

location /sitemaps/ {
        root /var/www/production/current;
        try_files $uri =404;
        allow all;

Pub folder the name suggests as publicly accessible folder, so moving the file sitemap.xml from HTML to the pub folder will resolve the issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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