WP-RestAPI and xml sitemap

Using the WP-RestAPI to pull a wordpress blog into an angularjs application. Works extremely well. The blog is using Yoast SEO for the for meta descriptions and keywords. I would like to use the yoast xml sitemap as well for submitting to google. However, because of route structure I need to save the sitemap to a different location than the root wordpress folder. I have also tried using the Google Sitemap Generator plugin. With neither plugin can I seem to change where the sitemap is saved. Looking for any advice on how I could make this work.

Topic rest-api plugin-wp-seo-yoast google-xml-sitemaps Wordpress

Category Web


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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.