0

Which rewriterule I should write?I have a lot of sitemap.xml files placed in folders separately one by one

The structure looks like this:

/sitemaps/moscow/sitemap.xml
/sitemaps/warsaw/sitemap.xml
/sitemaps/paris/sitemap.xml

and so on...

I would like to get them by going on next urls:

moscow.mydomain.com/sitemap.xml
warsaw.mydomain.com/sitemap.xml
paris.mydomain.com/sitemap.xml

...

So I need a redirect from http://moscow.mydomain.com/sitemap.xml to http://moscow.mydomain.com/sitemap.xml

Which rewriterule I should write in .htaccess file?

UPDATE

Thanks, but I found out a right solution, here it is:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com$
RewriteRule ^sitemap.xml$ sitemaps/%1/sitemap.xml [L]  

Works strictly as I wanted to!

0

1 Answer 1

0

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^sitemaps/([^/]+)/(sitemap\.xml)$ http://$1.mydomain.com/$2 [L,NC,R=301]
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.