4
4
4upik2017-10-16 19:47:27
Nginx
4upik, 2017-10-16 19:47:27

Nginx redirect from specific url to file?

The site uses subdomains, subdomains are managed through the site engine, i.e. each subdomain does not have folders, you need to create your own sitemap.xml for each subdomain, how to make it so that when you open subdomain.domain.com/sitemap/sitemap.xml, the file that actually finds domain.com/subdomain/sitemap.xml opens. Let me remind you that the subdomain is controlled through the engine.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Mukovoz, 2017-10-16
@4upik

If the difference is only in the domain, you throw a sitemap for one site, and in Nginx you write like this.

location ~ \.xml$ {
         sub_filter_once off;
         sub_filter_types *;
         sub_filter_last_modified on;
         sub_filter 'site.ru' $host;
        }

Instead of site.ru, you specify the address of the site that is included in the sitemap.
Or if you still need different files
location = /sitemap.xml {
alias /var/www/site.ru/sitemap-$host.xml;
}

True, the second option has not been tried in practice, if it does not work, write. In general, I recommend the first one.
Or so
location = /sitemap.xml {
rewrite ^.*$ /sitemap-$host.xml  break;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question