This has been an issue in core for a while, http://core.trac.wordpress.org/ticket/10722.
The simplest solution is to just overwrite the headers on ‘template_redirect’. You can replace them as long as you haven’t started any output yet, which you shouldn’t have at this point. Just call status_header( 200 );
No cache headers are also sent when the WP Class sends the 404 headers, so you’ll probably want to replace those with information based on the content you’re pulling from that PHP page.
Related Posts:
- Filter to change the content of 404 page
- A tool to analyze rewrite rules? [closed]
- Making a plugin file accessible via url rewrite?
- How to Rewrite WordPress URL for a Plugin
- Custom Rewriting to Plugin with Parameters
- Add rewrite rule in plugin: with .htaccess in plugin folder or using WordPress functions
- Removing rules from .htaccess
- Mapping multiple URLs to same page
- Rewrite Point Doesn’t Work on Custom Taxonomy
- Rewrite url for existing page without flush_rewrite_rules
- Set a specific page as 404 – not found via my own plugin
- URL rewriting must be activated manually for my plugin
- How to change the URL pattern for single post view
- Why doesn’t flush_rewrite_rules run on plugin activation?
- Redirect traffic to plugin
- Append country to ‘pretty’ url but serve same page
- How To Consistently Enforce Rewrite Rule in Plugin Development
- Show custom data instead of 404
- 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
- Set a CPT slug as a base name for all the taxonomies
- 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
- Plugin Development – Get Admin Url (Including cases where wp-admin is not used)
- If $var is empty, return 404.
- Forward an old url rewrite scheme to a new one?
- Form submission to another page returning 404 error [duplicate]
- Rewriting Image URLs from dynamic to original
- Custom Path for a Plugin
- Custom post type change permalink query
- Check current URL is 404 in pre_option_stylesheet filter hook
- 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
- Scripts/styles not loading on cloned WP Site when logged in
- 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?
- 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
- Plugin – Proper way to handle 404 pages?
- URL rewrite parameter lost (add_rewrite_rule)
- Custom rewrite, url path with parameters to a page
- Add screen options to custom admin pages
- WordPress and PHP Sessions – Security and Performance
- WordPress Hook for user register
- Must-use plugins autoloader: How to use get_plugins() correctly?
- Changing upload directory for plugin uploads only
- Upload file to remote storage
- One time username change from frontend?
- How to extend a plugin like we do a theme?
- How to add custom text in wordpress logs
- Front-End Interfaces Without Shortcodes
- How to not let a user with a new role edit users that have administrator role?
- async code or cron job?
- WordPress not working on localhost
- manage_posts_custom_column, showing serial number using increment in loop
- Custom delete option button in plugin settings
- $_FILES empty on created_{taxonomy} and create_{taxonomy} yet is is not on edit_{taxonomy}
- Storing data in wordpress database from ajax call from different website
- Prevent invalid or empty values from being saved to the database and retain the form field values upon error
- Hide shortcodes “code” when using the “editor” the same as wordpress do with “gallery”
- How do I access the menus produced by Dashboard > Appearance > Menus
- Determining URIs for plugin pages
- Filter Categories widget to allow custom sorting?
- Custom Rest Endpoint: Post/Put/Patch not working
- How to allow only two (or more) users access to a plugin
- Admin Subpages without Menu entry
- Add code to template dynamically
- Thousands of 404 errors on old posts due to embedded links
- Creating posts with links from a txt file
- Detect if requested page is PWA on server side
- Allow user to add the php code in wp_mail()
- Hiding WordPress REST endpoints from public viewing using Basic Authentication
- Plugin setting page – update_option problem
- WordPress Plugin Update Process
- Registration form Plugin… Email confirmation
- How to display posts list on my plugin page?
- Is there a canonical way for a plugin to install a mu-plugin or drop-in?
- Calling get_header() with installed FSE theme
- Add Datepicker field choice to Event Tickets Plus plugin
- Access DOM Element in Gutenberg Block on WP Admin Post Edit Screen
- Remove slug of multiple custom post types with and without hierarchical