Ad

Mod-rewrite Rule For Sitemap.xml

- 1 answer

I am using a CMS that hosts multiple websites simultaneously and I am seeking a method to properly serve sitemap.xml files for each site. I have concluded that a mod-rewrite rule will be the most effective solution for this.

My idea is to have a /sitemaps/ directory with the site map for each domain named as the domain name, i.e. /sitemaps/acmewidgets.com.xml

Since the appropriate sitemap url would be acmewidgets.com/sitemap.xml I need assistance with creating a mod-rewrite rule that will map this accordingly.

Thank you!

Ad

Answer

RewriteRule /?sitemap.xml %{DOCUMENT_ROOT}/sitemaps/%{HTTP_HOST}.xml [L]
Ad
source: stackoverflow.com
Ad