WP 5.5 core sitemaps not working in nginx

WP 5.5 was just released and contains a new core sitemaps feature. You access the sitemap from http://yoursite.com/wp-sitemap.xml

With a fresh site and no other issues this works when Apache is the web server but gives a 404 if nginx is the web server.

+1. Can confirm.

Try add the following to site.conf.hbs (before the WordPress config segment):

location ~* /[wp\-]*sitemap.*\.xml {
    try_files $uri $uri/ /index.php$is_args$args;
    # return 200 "Match found \n";
    allow all;
    log_not_found off;
    access_log off;
}

location = /robots.txt {
    try_files $uri $uri/ /index.php$is_args$args;
    allow all;
    log_not_found off;
    access_log off;
}

Source:

1 Like