wordpress-seo icon indicating copy to clipboard operation
wordpress-seo copied to clipboard

[Feature Request] Provide ability to make sitemap be output at a higher level / different url path

Open Pcosta88 opened this issue 9 years ago • 6 comments

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.

Pcosta88 avatar Feb 23 '17 18:02 Pcosta88

Please inform the customer of conversation # 181370 when this conversation has been closed.

Pcosta88 avatar Feb 23 '17 18:02 Pcosta88

Please inform the customer of conversation # 244291 when this conversation has been closed.

Pcosta88 avatar Oct 25 '17 19:10 Pcosta88

Please inform the customer of conversation # 309850 when this conversation has been closed.

devnihil avatar Feb 16 '18 14:02 devnihil

Please inform the customer of conversation # 335591 when this conversation has been closed.

devnihil avatar Mar 29 '18 18:03 devnihil

Please inform the customer of conversation # 334979 when this conversation has been closed.

devnihil avatar Mar 29 '18 19:03 devnihil

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.

CarolineGeven avatar May 25 '18 14:05 CarolineGeven