regex - Redirect sitemap.xml to a file in /assets/sitemap/ using htaccess -
if have subdomain, how can redirect it's sitemap.xml file found in /assets/sitemap?
subdomain1.example.com/sitemap.xml -> /assets/sitemap/subdomain1.xml subdomain2.example.com/sitemap.xml -> /assets/sitemap/subdomain2.xml
i used static code how make dynamic depending on subdomain name?
rewriteengine on rewriterule ^sitemap\.xml /assets/sitemap/subdomain1.xml [l]
you can use rewritecond
, capture subdomain name there:
rewriteengine on rewritecond %{http_host} ^(?!www\.)([^.]+) [nc] rewriterule ^sitemap\.xml$ /assets/sitemap/%1.xml [l,nc]
Comments
Post a Comment