WP-RestAPI and xml sitemap

Let’s assume your plugin is writing to the /usr/share/wordpress/sitemap_index.xml filesystem location, but you want it can be accessed through http://www.website.com/sitemap_index.xml as if the xml file were stored in /var/www/html/sitemap_index.xml. You can use the alias directive then, available in mainstream webservers Apache and NginX:

For an alias in NginX, you put this inside the server of your public website:

location /sitemap_index.xml {
    alias /usr/share/wordpress/sitemap_index.xml;
}

For Apache the alias it’s like this, inside the virtual host of your website:

Alias "/sitemap_index.xml" "/usr/share/wordpress/sitemap_index.xml"

Again, I’m only assuming filepaths and filenames, but if you need more specific directives, for another webserver, or differente paths/names, please comment it, or even better: update your question to make my answer match.