XML Sitemap rewrite rules for NGINX

Need help with this?
Purchase All in One SEO Pack Pro to get dedicated support from us.

Buy Now

If you’re getting a 404 for your All in One SEO Pack XML sitemap on NGINX, then please use the following rewrite rules in your NGINX config file (if you don’t know what to do with these, then you’ll need to contact your hosting company for assistance):

These rules are for All in One SEO Pack Pro v3.1 and later only:

#rewrite rules for AIOSEOP XML Sitemap v3.1
rewrite ^/sitemap.xml$ /index.php?aiosp_sitemap_path=root last;
rewrite ^/sitemap.xml.gz$ /index.php?aiosp_sitemap_path=root last;
rewrite ^/(.+)-sitemap.xml$ /index.php?aiosp_sitemap_path=$1 last;
rewrite ^/(.+)-sitemap.xml.gz$ /index.php?aiosp_sitemap_path=$1 last;
rewrite ^/(.+)-sitemap(\d+).xml$ /index.php?aiosp_sitemap_path=$1&aiosp_sitemap_page=$2 last;
rewrite ^/(.+)-sitemap(\d+).xml.gz$ /index.php?aiosp_sitemap_path=$1&aiosp_sitemap_page=$2 last;

You might also need to use these rewrite rules if /sitemap.xml keeps redirecting to you to /sitemap_index.xml, which is the sitemap slug of a competing SEO plugin. You’ll also need to remove the rewrite rules for that specific plugin.

*These rules will work for 99% of users. In some cases, such as if you have WordPress installed in a subdirectory, there may be modifications you’ll need to make.

If this doesn’t work for you, then please contact us.

  • Was this helpful ?
  • YesNo
Skip to toolbar