Thursday, August 14, 2014

Nginx - Simple dynamic sitemap rewrite configuration

A little note to remember...
The main goal is to create dynamic loading sitemap.xml file from some directory.
At the begining we have locale code. And sitemap file can requested from some directory.
Files should be placed to a particular directory.


location ~ /sitemap.xml|/([a-z][a-z]|[a-z][a-z]-[a-z][a-z])/(.*)sitemap.xml {
    root   /usr/local/www/apache22/data/project/;
    index /sitemap/sitemap.xml;
    try_files /sitemap/$1/$2/sitemap.xml /sitemap/$1/sitemap.xml;
}