Instead of index.php/reco/?b=$1
, try this:
"$wp_rewrite->index?pagename=reco&b=" . $wp_rewrite->preg_index( 1 )
You should also append a $
to your reco/([^/]*)/?
regex to ensure the rule only matches the entire path, and not just the beginning.
Then flush your rules afterwards (just re-save your permalink settings in admin).
Update: Try using the page_rewrite_rules
filter instead, and use get_query_var( 'b' )
:
function wpse_139259_page_rules( $rules ) {
return array(
'reco/([^/]+)/?$' => 'index.php?pagename=reco&b=$matches[1]',
) + $rules;
}
add_filter( 'page_rewrite_rules', 'wpse_139259_page_rules' );
Related Posts:
- add_rewrite_rule not working for page var
- WordPress URL rewrite regex
- Rewrite Rule for Custom Page with Query Vars in URL
- WordPress rewrite rules for state and city
- How to properly rewrite url by custom var
- Rewrite query string to path
- How can I reduce the number of rewrite rules?
- Rewrite rule regex help required
- Need help with regex
- Standard Regex syntax doesn’t work in WordPress rewrite rule
- How to combine nearly identical custom rewrite rules for WordPress
- Dynamic Endpoints
- How to add custom rewrite rule to .htaccess?
- How do I remove a rewrite rule?
- Problem with add_rewrite_rule and pagination (paged and page query_vars)
- How to change default page slug?
- Rewrite url for custom post type
- add_query_vars and add_rewrite_rules
- rewrite_rule() not preserving the query string
- Need help with rewrite_rules_array
- Why does wordpress still strip my query var?
- When to call `add_rewrite_rule` for safety
- Custom rewrite rules are sending everything to index.php
- Rewrite rules goes away
- add_rewrite_rule again
- Rewrite Rule for Post “Subpage”, with pagination
- Need to make a php file inside theme accessible via url
- Rewrite loading custom template file but is_home() returns true, and there’s no 404
- Rewrite rule for admin-ajax.php
- Evaluating a external rewrite rule before internal wordpress rewrite rule
- Rewriting rules: difference between ‘init’, ‘rewrite_rules_array’, ‘generate_rewrite_rules’?
- Multiple Permalinks for Same Post
- add_rewrite_rule not working for language specific characters
- How to Modify Existing Rewrite Rules?
- Custom rewrite rule
- Single Redirection Rule for Pages and Archive links
- Is it possible to remove feeds from rewrites?
- Rewrite of URL with ‘[‘ ‘]’ or ‘(‘ ‘)’ as literals
- Flush Rewrite Rules on init or rest_api_init?
- Remove “/page/1” from the URL
- Rewrite URL – insert custom variables as a directory path
- Can’t add external rewrites
- WordPress rewrite rules don’t need ^?
- Rewrite rule to prettify two $_GET variables while in a new endpoint from a page
- custom template rewrite
- 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
- Custom Rewrite rule to captured post (rewrite rule to rewrite rule)
- Rewrite the default post object’s permalink
- QSA Rewrite Rule
- Enpoint Not Found in Rewrite Tag Permalink
- How to pass url as a parameter in a add_rewrite_rule
- Per Page Permalink Structure for Page Post Type
- Custom Rewrite Rules
- Customise particular RSS permalink
- URL Rewrite with Custom Variables
- ReWrite rule for files of a previously standalone blog moved to network
- RSS feed rewrite matching wrong rule
- Rewrite /category/cars into /topics/cars
- Best way to trigger rewrite rules
- Trouble with question mark in rewrite rule
- show ALL latest posts with archive.php on example.com/latest
- What URL rewriting rule should I write to retrieve a var in the URL?
- Custom rewrite rule not working
- Redirect URL to an existing page with query string or #! added on
- How do I make WordPress revise an .htaccess file a certain way?
- How can I allow trailing slashes on some URLs without a redirect, but not on others?
- Can’t use a specific custom URL (slug)?
- How to change an existing wordpress page rewrite rule?
- URL rewriting in wordpress using parameters
- Adding the amp url prefix to the beginning
- Rewrite rules – page does not exist
- Use URI suffix as parameter and ignore when resolving page
- Why wordpress rewrite my custom URL?
- Rewrite Rules are Redirecting
- How to redirect to a login virtual page?
- Rewrite rule not working, suspect redirect string
- Issue with custom rewrite for products and permalinks
- Prefix only some posts with a custom prefix
- Help adding custom url, rewrite_rules_array
- How to use a capture from a rewrite rule inside a php file (like single.php)?
- url rewriting on custom post type
- Broken page redirect
- Rewrite rule not redirecting correctly
- Custom taxonomy Rewrite Rule
- add_rewrite Rule
- rewrite rule of post when accessed from archives pages
- Rewrite rule is not working
- How to make a custom route with any-string-part/number-part pointing to an existing page?
- Rewrite Rule & Regex – Extract ‘cat-name’ and ‘page-number’ from http://domain.com/custom-post-type/category/cat-name/page/page-number
- rewrite rule for home/index page
- Post Type Rewrite Custom
- Rewrite URL variable to custom path
- Rename page URL
- Help with url rewrite
- Add additional URL variations for a Post
- Wrong rewrite rules