Since you are using Nginx as your web-server, please configure the following rewrite rules in case you get 404 Not Found errors for your sitemap

Just installed Google XML Sitemap into the WordPress Ubuntu server. As soon as the plugin installed, starts displaying a message:

Since you are using Nginx as your web-server, please configure the
following rewrite rules in case you get 404 Not Found errors for your
sitemap:

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;

Went to Ubuntu Server and opened the Nginx Config file which was located at- /etc/nginx/sites-available/blogforcodes

Pasted the above Rewrite Rules in nginx config file which now looks like this-

2018-04-24_0939

Restarted the nginx using command sudo systemctl restart nginx and now https://blog.enginesoft.in/sitemap.xml is resolving.

Shared because it might help someone 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *