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

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -