Custom rewrite rules get a trailing slash automatically?

[ad_1]

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]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer