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_varsarray.
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
- Passing arguments to a admin menu page callback?
- Add async script
- Allowing for multiple template views on the Gallery Settings page when using the Visual Editor
- why don’t I get error messages in admin when developing?
- How to check if certain plugin exists and in expected version
- How to add SQL file with PHP to WordPress database [closed]
- Platform/Website that Supports Crowd-Funded WordPress Projects? [closed]
- Get user id for delete and update selected user
- How can I call template partials inside my custom plugin
- Creating table with plugin is not working
- How to delete an user including data from custom database tables
- Custom Post Type rewrite
- Multiple options pages validation for a plugin
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- Woocommerce Composite Products – Add a composite product to cart programmatically via ajax [closed]
- Add a page in admin without adding menu item
- wp_get_post_terms Order by not working
- Naming conventions when using (PHP5) namespaces?
- Readme.txt seems to be cached but not the version
- Issue on Checkbox with Custom Option Page
- Encoding Method for URLs?
- Store custom meta box data as serialized array
- How to customize sub-URLs in a wordpress website (.htaccess)
- Why won’t this submenu page show? – My First WordPress Plugin
- Multiple dynamic Tax Query – pass taxonomy argument from array
- ACF Field value in wordpress login message filter
- ajax stopped working when not logged in wordpress
- Overriding the template files using a plugin for all themes
- Determine if the current page, is being edited
- Fullwidth slider using background image Flexslider WordPress
- Return value of $wpdb->update() query in plugin is wrong
- Plugin files not updated (cache cleared)
- How to limit the number of posts a user can view based on status
- WordPress plugin tables become corrupt
- How to call a new php page inside a plugin page?
- How can i call from custom fields to the category editor?
- If I want to create new taxonomies (e.g. Project / Documents / Etc…) is it better to create them in the theme’s functions.php or within a plugin? [duplicate]
- Advanced Custom Fields conflicting with custom plugin when saving custom field
- Query posts which are related via postmeta