How to Set up sitemap.xml on Apache Servers?
Squirrly SEO automatically generates your sitemap when you enable the XML Sitemap settings.
On some Apache servers, based on the server configuration, you may need to add server-level rewrites to correctly set up the sitemap.xml file.
For this purpose, we recommend setting the following rules for Squirrly SEO sitemap in .htaccess file. Add them above the # BEGIN WordPress block. Apache reads the rules from top to bottom, and the WordPress block ends the processing (the L flag) for addresses that aren’t real files, such as sitemap.xml.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^sitemap.xml$ /index.php?sq_feed=sitemap [QSA,L]
RewriteRule ^sitemap-posts.xml$ /index.php?sq_feed=sitemap-post [QSA,L]
RewriteRule ^sitemap-pages.xml$ /index.php?sq_feed=sitemap-page [QSA,L]
RewriteRule ^sitemap-categories.xml$ /index.php?sq_feed=sitemap-category [QSA,L]
RewriteRule ^sitemap-tags.xml$ /index.php?sq_feed=sitemap-post_tag [QSA,L]
RewriteRule ^sitemap-archives.xml$ /index.php?sq_feed=sitemap-archive [QSA,L]
RewriteRule ^sitemap-authors.xml$ /index.php?sq_feed=sitemap-author [QSA,L]
RewriteRule ^sitemap-custom-taxonomies.xml$ /index.php?sq_feed=sitemap-custom-tax [QSA,L]
RewriteRule ^sitemap-custom-posts.xml$ /index.php?sq_feed=sitemap-custom-post [QSA,L]
RewriteRule ^sitemap-([a-z]+).xml$ /index.php?sq_feed=sitemap-$1 [QSA,L]
</IfModule>
The last rule covers the other files: sitemap-home.xml, sitemap-product.xml, sitemap-news.xml and sitemap-attachment.xml.
The QSA flag keeps the paginated sitemaps working. The sitemap index links to addresses such as sitemap-posts.xml?page=2, sitemap-custom-posts.xml?type= followed by a post type name, or sitemap-custom-taxonomies.xml?taxonomy= followed by a taxonomy name. A RewriteRule pattern never sees the query string, and without QSA the new sq_feed query replaces the original one, so page 2 would load page 1. With QSA, Apache adds the original page, type and taxonomy parameters after sq_feed.
If your WordPress permalinks are set to Plain, Squirrly uses addresses such as /?sq_feed=sitemap-post and you don’t need these rules.
After you save the .htaccess file, open https://example.com/sitemap.xml (with your own domain) and click a few of the sitemaps it lists, including sitemap-tags.xml and a page 2, to check that each one loads.
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.
On an NGINX server, use the rules from How to Set up sitemap.xml on NGINX Servers? instead.



