Skip to main content

WordPress Sitemap 404 Not Found Error with Nginx

wordpress sitemap 404 not found

Sitemap 404 Not Found

If you are using Nginx as your web server and install the Google XML Sitemap plugin on your WordPress site, then when you submit your xml sitemap to Goolge Search Console, you may get a WordPress sitemap 404 not found error.

sitemap 404 not found


The Solution

The solution is simple, just copy the following lines to your nginx virtual host file. On CentOS/Redhat Server, the virtual host file usually is /etc/nginx/conf.d/ On Debian/Ubuntu Server, it is located at /etc/nginx/sites-available/

rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;

Save the virtual host file and reload Nginx.

sudo systemctl reload nginx


sudo /etc/init.d/nginx reload

When you first installed Google XML Sitemap plugin, it will give a warning if you are using Nginx. The above rewrite rules can also be found when you go to Settings > XML-Sitemap.

Rate this tutorial
[Total: 0 Average: 0]