views:

9

answers:

1

Hi,

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!

+1  A: 
RewriteRule /?sitemap.xml %{DOCUMENT_ROOT}/sitemaps/%{HTTP_HOST}.xml [L]
Ignacio Vazquez-Abrams
That appears to work, but it seems to redirect to the actual sitemap url instead of simply serving the file while retaining the requested url. Does that make sense? Thank you so much for your help.
sterling
It should not, as long as the `R` flag is not present.
Ignacio Vazquez-Abrams
Actually, what you provided works perfectly. Thank you. The issue was that another rewrite rule was adding www to the HTTP_HOST.
sterling