nginx drupal sitemap 404 not found

  • Post author:
  • Post last modified:May 12, 2022
  • Reading time:1 mins read

1.0 Error

While trying to open sitemap.xml of a site served by nginx and built using Drupal CMS, the 404 Not Found error was received. The nginx log file, error.log gave the error as, 80 open() sitemap.xml failed (2: No such file or directory).

2.0 Solution

The error was resolved by adding the following lines to the nginx configuration file, /etc/nginx/nginx.conf.

location = /sitemap.xml {
    try_files $uri @rewrite;

location @rewrite {
    rewrite ^/(.*)$ /index.php?q=$1;

Karunesh Johri

Software developer, working with C and Linux.