You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yoast SEO is adding rewrite rules by filtering the rewrite rules array using the filter option_rewrite_rules rather than using the add_rewrite_rule rule functionality and adds its sitemaps related rewrite rules at the top of the array.
As a result, the below rewrite rule added by Yoast SEO takes precedence :
[([^/]+?)-sitemap([0-9]+)?.xml$] => index.php?sitemap=$matches[1]&sitemap_n=$matches[2]
The rewrite rule that this plugin adds is [^news-sitemap.xml$] => index.php?news-sitemap=true.
As the regex "([^/]+?)-sitemap([0-9]+)?.xml$" catches the news-sitemap.xml, it is going to 404 page
This can be resolved by having the sitemap_slug to be different such that it is not caught by Yoast's rewrite rule regex "([^/]+?)-sitemap([0-9]+)?.xml$"
May be even allowing a filter to change the sitemap slug could work?
For now, the only option to make this working is to use the filter "option_rewrite_rules" and manually place the '^news-sitemap.xml$' related rule to the top of the array, making it take precedence over the Yoast SEO's rules.
Steps to Reproduce
Have a website with Yoast SEO plugin Installed and activated
Install this plugin
Flush Permalinks
Try visit your-site.com/news-sitemap.xml
It shows 404.
Screenshots, screen recording, code snippet
No response
Environment information
not relevant
WordPress information
Encountered this on WordPress 6.6.2
Yoast SEO Version 22.7 and event the latest Version 23.4
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Describe the bug
Yoast SEO is adding rewrite rules by filtering the rewrite rules array using the filter
option_rewrite_rules
rather than using theadd_rewrite_rule
rule functionality and adds its sitemaps related rewrite rules at the top of the array.As a result, the below rewrite rule added by Yoast SEO takes precedence :
[([^/]+?)-sitemap([0-9]+)?.xml$] => index.php?sitemap=$matches[1]&sitemap_n=$matches[2]
The rewrite rule that this plugin adds is [^news-sitemap.xml$] => index.php?news-sitemap=true.
As the regex "([^/]+?)-sitemap([0-9]+)?.xml$" catches the
news-sitemap.xml
, it is going to 404 pageThis can be resolved by having the sitemap_slug to be different such that it is not caught by Yoast's rewrite rule regex "([^/]+?)-sitemap([0-9]+)?.xml$"
May be even allowing a filter to change the sitemap slug could work?
For now, the only option to make this working is to use the filter "option_rewrite_rules" and manually place the '^news-sitemap.xml$' related rule to the top of the array, making it take precedence over the Yoast SEO's rules.
Steps to Reproduce
Screenshots, screen recording, code snippet
No response
Environment information
not relevant
WordPress information
Encountered this on WordPress 6.6.2
Yoast SEO Version 22.7 and event the latest Version 23.4
Code of Conduct
The text was updated successfully, but these errors were encountered: