@domenico.weimann
To serve multiple sitemap.xml files in Nginx, you can use the location
directive to configure different paths for each sitemap file. Here's an example:
- Open your Nginx configuration file. This is usually located at /etc/nginx/nginx.conf or /etc/nginx/conf.d/default.conf.
- Inside the server block, add separate location blocks for each sitemap file you want to serve. For example:
server {
...
location /sitemap1.xml {
alias /path/to/sitemap1.xml;
types { } default_type "text/xml";
}
location /sitemap2.xml {
alias /path/to/sitemap2.xml;
types { } default_type "text/xml";
}
location /sitemap3.xml {
alias /path/to/sitemap3.xml;
types { } default_type "text/xml";
}
...
}
In this example, we have three sitemap files: sitemap1.xml, sitemap2.xml, and sitemap3.xml. Adjust the file paths to match your actual sitemap files.
- Save the configuration file and exit the text editor.
- Run a syntax check to ensure that the configuration file doesn't contain any syntax errors:
sudo nginx -t
- If the syntax check passes, reload the Nginx configuration to apply the changes:
sudo systemctl reload nginx
After following these steps, you should be able to access the sitemap.xml files by visiting the corresponding URLs on your Nginx server, such as http://example.com/sitemap1.xml
, http://example.com/sitemap2.xml
, etc.