I just did a test and it seems like the rewrite rules imply ^ if you do not specify it. In my test I found:
rule 'foo' matched url 'foo'
rule '^foo' matched url 'foo'
rule 'foo' did not match url 'afoo'
rule '^foo' did not much url 'afoo'
rule '.*foo' matched url 'afoo'
So i had to explicitly add some matching regex at the start for it to match extra characters at the start.
‘foo’ did not match ‘afoo’
Personally, I like to be specific, so I think you’re right it makes sense to make your regex '^sitemap\.xml$'
because that’s what it will do.
Related Posts:
- Rewrite rule to load images from production does nothing
- Rewriting “pretty” blog category URL with htaccess / add_rewrite_rule() causes 404 page
- How do I make WordPress revise an .htaccess file a certain way?
- Pretty URL via Rewrite
- Can’t get pretty permalinks to work without index.php
- How to create custom URL routes?
- Masking wp-content/themes/name/images to just images directory using htaccess
- How to add custom rewrite rule to .htaccess?
- How to change default page slug?
- SEO Friendly URLs for my plugin categories
- Mod_rewrite delete parameter in 301 Redirect
- Custom rewrite rules are sending everything to index.php
- WordPress keeps writing rewrite rules to .htaccess
- WordPress Rewrite
- Dynamic URL, not a physical page within the database
- Need to make a php file inside theme accessible via url
- Evaluating a external rewrite rule before internal wordpress rewrite rule
- Custom rewrite rule
- hard flush_rewrite_rules() not regenerating .htaccess
- Map alt domain to specific section of website w/o MU
- Rewrite Rules Are Redirecting and Not Passing VARs
- Adding rewrite rules directly to .htaccess file
- Custom rewrite not working
- Url Rewriting a dynamic wordpress page
- My WP_options db rewrite_rules Does Not Work
- Disable Pagination on Pages
- WP is ignoring .htaccess rewritten URL
- a one-off rewrite rule
- .htaccess rewrite
- Rewrite wp-login.php URLS to static pages?
- Change htaccess to redirect to index.php in subfolder
- Rewrite custom post type URL parameters
- How to remove wordpress directory slash
- Changed pagination URLS to use p= instead of paged=
- Rewrite URLs – Custom Post Type – Post Slug, Taxonamy Slug
- URL Rewriting for PHP script on an image URL
- Change pagination url format
- Custom Rewrite rule to captured post (rewrite rule to rewrite rule)
- Map secondary domain to other’s virtual subfolder
- URL rewriting with custom user meta “/%shop_name%/gallery/%gallery%”
- WordPress keeps writing rewrite rules to .htaccess
- Customise particular RSS permalink
- RSS feed rewrite matching wrong rule
- Localize URL bases
- How can I create custom URL routes?
- Rewrite specific action url
- force www rewrite if wordpress put in a folder
- Rewrite rule that wp-login.php?action=register is left alone
- How to change an existing wordpress page rewrite rule?
- ModRewrite not working properly
- Migration from old CMS to WordPress 301 redirection rules?
- Custom Rewrite for Profiles
- Additional .htaccess rules based on wp page
- What is the proper way to use add_rewrite_rule to remove the (question mark)?
- help with rewrite_tag and rewrite_rule for custom page GET variables [duplicate]
- How to redirect a virtual page (e.g. /blog) to the home page?
- Add rewrite endpoint and .htaccess
- Rewrite Page Parameters
- WP-Include rewrite directory
- Problem with add_rewrite_rule and pagination (paged and page query_vars)
- Why does wordpress still strip my query var?
- When to call `add_rewrite_rule` for safety
- Rewrite rules goes away
- Rewrite Rule for Post “Subpage”, with pagination
- unexpected problem in url rewrite
- Rewrite loading custom template file but is_home() returns true, and there’s no 404
- Rewrite rule for admin-ajax.php
- Rewrite WordPress Custom URL
- add_rewrite_rule not working for language specific characters
- Add query string to url and display it as normal url part /folder/
- Is it possible to remove feeds from rewrites?
- Flush Rewrite Rules on init or rest_api_init?
- WordPress .htaccess – route other URLs to another app
- Rewrite URL – insert custom variables as a directory path
- How to properly rewrite url by custom var
- Can’t add external rewrites
- Changing RSS feed URL structure
- Preserve Domain Alias
- How to building pretty URLs to reflect category hierarchy?
- WordPress Rewrites – How can I pass a variable to Custom Post Type?
- Need to add rewrite rule that adds in additional information about the post to url
- add_rewrite_rule is redirecting instead of rewriting url
- Rewrite rules automatically for pages using specific template
- How to pass url as a parameter in a add_rewrite_rule
- Per Page Permalink Structure for Page Post Type
- Custom rewrite rule not working
- How can I allow trailing slashes on some URLs without a redirect, but not on others?
- Adding the amp url prefix to the beginning
- Multiple permalink with and without category for same post
- Custom Params in URL
- Help adding custom url, rewrite_rules_array
- Broken page redirect
- No Ones Been Able to Override my WordPress Rewrite Rule Issue!
- Add ReWrite from Old Pages to WordPress (remove .php)
- add_rewrite Rule
- Fully mask *all* traces of WordPress installation subdirectory?
- Redirect A URL Pattern In WordPress Using .htaccess
- Rewrite Question
- How to make a custom route with any-string-part/number-part pointing to an existing page?
- Programmatically add a custom url route “/category/index.json” to return a collection of posts in json