Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When site uses Yoast SEO, the rewrite rule is conflicting and the one added by Yoast SEO takes precedence, causing 404 for /news-sitemap.xml #47

Open
1 task done
pushpakpop opened this issue Sep 17, 2024 · 0 comments
Labels
type:bug Something isn’t working.
Milestone

Comments

@pushpakpop
Copy link

Describe the bug

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

  1. Have a website with Yoast SEO plugin Installed and activated
  2. Install this plugin
  3. Flush Permalinks
  4. Try visit your-site.com/news-sitemap.xml
  5. 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
@pushpakpop pushpakpop added the type:bug Something isn’t working. label Sep 17, 2024
@jeffpaul jeffpaul moved this from Incoming to To Do in Open Source Practice Sep 17, 2024
@jeffpaul jeffpaul added this to the 1.2.0 milestone Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn’t working.
Projects
Status: To Do
Development

No branches or pull requests

2 participants