Hello, I’m trying to write a custom sitemap.xml plugin, so I looked the code of some other sitemap plugin and tried using the same hook (rewrite_rules_array) but for some reason when I do it my rules get a trailing slash added automatically?
For example when I wrote
function curious_sitemap__filter_rewrite_rules($rules) {
$new_rules = array(
‘test$’ => ‘index.php?curious_sitemap=root’,
);
return array_merge($new_rules, $rules);
}
And I tried to access /test it redirected (301) to /test/
The rule still worked even though it didn’t match the pattern (I was able to use template_include to render my custom xml), but naturally I don’t want this slash.
I literally used the same code as a plugin that has a sitemap.xml rule without the slash. I tried various names without and with captures. I tried other hooks like add_rewrite_rule and generate_rewrite_rules. I tried `/?$`. But nothing seems to work? Wtf?
[ad_2]