NOTE: WordPress Rewrite API is not the same as Apache Rewrite module.
WP Rewrite API doesn’t redirect a request to another URL, it used to
parse current URL and fillquery_vars
array.
The issue is in the second parameter of you add_rewrite_rule
function call. It has to start from index.php?
and then there should be your arguments, like pid
, for example:
"index.php?pid=$matches[1]...."
So your add_init
function should be like this:
add_action( 'init', 'wpse8170_add_init' );
function wpse8170_add_init()
{
add_rewrite_rule('my-plugin/pages/tp(.*)\.php', 'index.php?pid=$matches[1]', 'top');
}
Don’t forget to flush rewrite rules by visiting Settings
» Permalinks
page.
Further reading:
Related Posts:
- Removing rules from .htaccess
- Append country to ‘pretty’ url but serve same page
- A tool to analyze rewrite rules? [closed]
- Making a plugin file accessible via url rewrite?
- Edit or Remove Plugin .htaccess Using The Admin Panel
- How to Rewrite WordPress URL for a Plugin
- Custom Rewriting to Plugin with Parameters
- Filter to change the content of 404 page
- Mapping multiple URLs to same page
- Pages 404 in wordpress
- Rewrite Point Doesn’t Work on Custom Taxonomy
- Rewrite url for existing page without flush_rewrite_rules
- Does WP Have a Function To Generate .htaccess RewriteCond?
- Custom rewrite rule serves content, but returns 404 error code
- URL rewriting must be activated manually for my plugin
- Error “Call to a member function switch_to_locale() on null” during insert_with_markers
- How to change the URL pattern for single post view
- Why doesn’t flush_rewrite_rules run on plugin activation?
- Redirect traffic to plugin
- Modifying the default WordPress .htaccess with a plugin
- How To Consistently Enforce Rewrite Rule in Plugin Development
- How can I rewrite a URL to pass requests to a custom method via AJAX? (I can’t use admin-ajax.php)
- Adding rewrite rule dynamically
- rewrite URL based on selected taxonomy for post page
- How to restrict access to image folder depending on whether product is purchased or not?
- Remove custom post type slug from URL and add taxonomy Slug
- Help writing custom function with rewrite endpoint that generates a page from dynamic content
- Possible to get all posts with my shortcode?
- add_rewrite_rule behaving strangely
- HowTo to add my rewrite rules at the beginning, redirect to the right page and flush the rules on plugin activation?
- Create page (not the post type) dynamically
- How can I add rewrite rules to a class-based plugin?
- configuration of .htaccess for add_rewrite_rule to make sense
- Do rewrites added with add_rewrite_rule() persist after plugin deletion?
- Plugin Development – Get Admin Url (Including cases where wp-admin is not used)
- Forward an old url rewrite scheme to a new one?
- Rewriting Image URLs from dynamic to original
- Custom Path for a Plugin
- .htaccess with WordPress – create my own pretty url with parameters (above WordPress settings)
- Custom post type change permalink query
- Change cannonical URL after changing url with add_rewrite_rule()
- Disabling Yoast, All-in-One, and Rank Math on Certain Pages within a Plugin
- WordPress custom url without using any of the custom tags given
- Using meta_key & meta_value in add_rewrite_rule
- How to force download a plugin generated file?
- How to pass a more variable with page/subpage in Wordprees URL?
- Any way to make Apache’s internal redirect work?
- Rewriting URLs with a query string
- How can I send an id over the url?
- Apache rewrite rules and wordpress problem
- Custom slug in url for CPT and taxonomy
- add_rewrite_rule not working
- Mapping multiple URLs to same page
- Use custom clean URLs for a plug in
- How to Rewrite WordPress URL for a Plugin
- Virtual Page with Registration form
- How to use permalink query to go to specific tabs in posts
- How to Rewrite WordPress URL for a Plugin
- redirect word-press page with page values
- URL rewrite parameter lost (add_rewrite_rule)
- Custom rewrite, url path with parameters to a page
- Pretty URLs for dynamically created product and pagination pages
- All Pages and Post are redirecting to 404 Not Found in wordpress
- Creating an installation zip file
- How to use nonce
- Remove All Taxonomies from Post On Update
- update_callback is not working in register_rest_field
- Run uninstall.php if a checkbox is checked from settings page
- WP Still Generating 150×150 Thumbnail Size Even After Un-Setting Small Size in Functions.php
- How to create ShortCode
- Where to use nonce
- Plugin index page code executes multiple times
- How to call code when adding WooCommerce menu items via woocommerce_account_menu_items
- Is it possible to load the css just on my plugin admin page?
- Duplicate shipping method logic to another shipping method [closed]
- How do I validate extra pin field on my WordPress login form page?
- REST Endpoint API 404
- add_action pre_term_description vs. pre_category_description
- How to check whether checkbox is checked in WordPress customizer
- How to create a wordpress widget that dynamically changes according to the page
- How to disable a jQuery plugin on WordPress plugin page
- jquery in wordpress plugin with depdendency
- Problem with autoloader and namespaces
- Non editable custom taxonomy
- How to Get Rid of Unwanted Backslashes in WordPress Form Input inside admin menu option
- Gutenberg – is it ok to load dependencies multiple times?
- Is it possible to use WP-CLI in a plugin (or theme)?
- Preventing double loading JS scripts (like React) when developing for Gutenberg
- Pass CF7 form data to plugin
- How to add custom post widgets as tags into wordpress
- How to display the specific post content by using POST ID
- Should I use wp-content/cache or [PLUGIN_DIR]/cache?
- How to register my code as a plugin
- Secruity Questions on a timer
- Make wordpress join default user metas with a column from another table while displaying the wp_users table on the users screen
- AJAX button with success callback. (Titan Framework)
- Is there any way to fire heartbeat API from for website visitors?
- How to output functions from plugin inside theme
- ajax working when function is on child theme but not in plugin page
- modify show UI of a registered taxonomy