[Feature Request] Provide ability to make sitemap be output at a higher level / different url path
By default the sitemaps will be available at the root of your domain: https://example.com/sitemap_index.xml.
For users who would want the sitemap be output at a different level or url path we should provide such an option. Eg, if you want your sitemaps to appear at https://example.com/foo/bar/sitemap_index.xml enter "foo/bar" below.
A user then provided a possible solution/suggestion
Then all you have to do is echo that string out when you add the rewrite rules on lines 32-34 here:
https://github.com/Yoast/wordpress-seo/blob/892238b5dbddf66bef6dee3d4467626e5ca02d19/inc/sitemaps/class-sitemaps-router.php#L32-L34
And also where you create the redirects for sitemap.xml on line 69-71:
https://github.com/Yoast/wordpress-seo/blob/892238b5dbddf66bef6dee3d4467626e5ca02d19/inc/sitemaps/class-sitemaps-router.php#L69-L71
So, the modified code might look something like:
add_rewrite_rule($sitemapPath . 'sitemap_index.xml$', 'index.php?sitemap=1', 'top' ); add_rewrite_rule( ''^' . $sitemapPath . '([/]+?)-sitemap([0-9]+)?.xml$', 'index.php?sitemap=$matches[1]&sitemap_n=$matches[2]', 'top' ); add_rewrite_rule(''^' . $sitemapPath . '([a-z]+)?-?sitemap.xsl$', 'index.php?xsl=$matches[1]', 'top' );
Where $sitemapPath is the string from the panel ending with a /, e.g., "/foo/bar" from he example above.
USE CASE to output Yoast XML Sitemap at another URL A. A user may have Wordpress for Joomla, from corePHP. Ie. our site root is https://siteroot.com/ and Wordpress is https://siteroot.com/blog B. BUT, /blog/ is dynamic, not a "real" directory… generated by Wordpress for Joomla, from corePHP.. C. So the XML sitemap can't be written to https://empowerednetworks.com/blog/sitemap_index.xml and therefore the user needs to output it elsewhere.
Please inform the customer of conversation # 181370 when this conversation has been closed.
Please inform the customer of conversation # 244291 when this conversation has been closed.
Please inform the customer of conversation # 309850 when this conversation has been closed.
Please inform the customer of conversation # 335591 when this conversation has been closed.
Please inform the customer of conversation # 334979 when this conversation has been closed.
This issue was discussed with @jdevalk and @jcomack. We've decided to not implement this, as it can cause quite a lot of new bugs.