Skip to content Skip to main navigation Skip to footer

How to Set up sitemap.xml on NGINX Servers?

Squirrly SEO automatically generates your sitemap when you enable the XML Sitemap settings.

On NGINX servers, you may need to add server-level rewrites in order to correctly set up the sitemap.xml file.

For this purpose, we recommend setting the following rules for Squirrly SEO sitemap in Nginx.conf:

location ~ ([^/]*)sitemap(.*).xml$ {  
rewrite ^/sitemap.xml$ /index.php?sq_feed=sitemap last;
rewrite ^/sitemap-posts.xml$ /index.php?sq_feed=sitemap-post last;  
rewrite ^/sitemap-posts.xml\?page=([0-9]+)$ /index.php?sq_feed=sitemap-post&page=$1 last;  
rewrite ^/sitemap-pages.xml$ /index.php?sq_feed=sitemap-page last;  
rewrite ^/sitemap-pages.xml\?page=([0-9]+)$ /index.php?sq_feed=sitemap-page&page=$1 last;  
rewrite ^/sitemap-categories.xml$ /index.php?sq_feed=sitemap-category last;  
rewrite ^/sitemap-tags.xml$ /index.php?sq_feed=sitemap-tag last;  
rewrite ^/sitemap-archives.xml$ /index.php?sq_feed=sitemap-archive last;  
rewrite ^/sitemap-custom-taxonomies.xml$ /index.php?sq_feed=sitemap-custom-tax last;  
rewrite ^/sitemap-custom-taxonomies.xml\?page=([0-9]+)$ /index.php?sq_feed=sitemap-custom-post&page=$1 last;
rewrite ^/sitemap-custom-taxonomies.xml\?page=([0-9]+)&type=([a-z]+)$ /index.php?sq_feed=sitemap-custom-post&page=$1&type=$2 last;  
rewrite ^/sitemap-custom-posts.xml$ /index.php?sq_feed=sitemap-custom-post last;  
rewrite ^/sitemap-custom-posts.xml\?page=([0-9]+)$ /index.php?sq_feed=sitemap-custom-post&page=$1 last; 
rewrite ^/sitemap-custom-posts.xml\?page=([0-9]+)&type=([a-z]+)$ /index.php?sq_feed=sitemap-custom-post&page=$1&type=$2 last; 
rewrite ^/sitemap-([a-z]+).xml$ /index.php?sq_feed=sitemap-$1 last; } 

NOTE! In case you are not 100% sure where to add these rules, we recommend reaching out to your web host or server admin and asking for further assistance.

Still Need Help?

If you’ve added the rewrite rules in the correct file, and you still encounter issues, they are likely linked to other settings on your server. You can always reach out to our support team via one of the available channels whenever you need more assistance.