$matches[1]
doesn’t work for external redirects, only internal (URL must start with index.php and handled by WordPress itself)
Try this
add_action('init', 'custom_rewrite_pdfURL');
function custom_rewrite_pdfURL() {
add_rewrite_rule('^carPDF/([^/]*)/?', 'wp-content/themes/exampletheme/templates/pdf-generator.php?productID=$1', 'top');
}
Don’t forget to flush permalinks
Related Posts:
- Clash of the rewrites
- Hijacking the URL for filtering
- custom htaccess rewrite rule for page
- Prevent WordPress from automatically correcting URLs
- Server (WordPress) redirects files that are not supposed to (using htaccess)
- Alias ‘wp-content’ directory to something shorter (framework?)
- WordPress .htaccess – route other URLs to another app
- Changing RSS feed URL structure
- add_rewrite_rule fro html to another url not working
- Preserve Domain Alias
- Wildcard forward all posts and pages with few exceptions
- React Router with WordPress
- Is WordPress API visible from PHP file called in htaccess
- How to customize sub-URLs in a wordpress website (.htaccess)
- WordPress is adding “category” word before my actual category name in url (and this is unsolicited)
- Multiple permalink with and without category for same post
- Use a template file for a specific url without creating a page
- Multiple endpoints to same page
- How to remove “admin.php?page=” from wp-admin using .htaccess?
- SEO Friendly URLs for my plugin categories
- How to create a specific frontend URL (not a Page) from a theme or plugin?
- Rewrite rules in .htaccess get overwritten?
- WordPress keeps writing rewrite rules to .htaccess
- WordPress Rewrite
- Dynamic URL, not a physical page within the database
- Passing & Reading URL Parameters with URL re-writing
- Woocommerce different URL for every table placed in the restaurant
- Taking a value from PHP_URL_PATH won’t work after WordPress 5.5 update
- Display content according to current URL
- Allow single quote in URLs
- htaccess: Remove trailing slash from URL ending with .xml/ only
- External/non-WP rewrite rule without QSA
- Remove all categories from URL
- Custom URL rewrite to specific page template
- Map alt domain to specific section of website w/o MU
- Rewrite rule to load images from production does nothing
- WordPress SSL (https) is not working with custom permalink
- Creating a dynamic URL structure
- How to redirect http://mydomain/blog/blahblah/ to http://mydomain/blahblah/ in wordpress htaccess?
- Append a query string to the end of every URL
- Double domain name in category URL-s
- Access files at new location using old file paths
- NextGEN Gallery Lightbox – Social Share URL Redirect
- Url Rewriting a dynamic wordpress page
- WordPress .htaccess blocks mine?
- My WP_options db rewrite_rules Does Not Work
- Rewrite Preview URL to include index.php
- How to disable URL rewriting for specific URLs?
- Adding special characters to slug?
- a one-off rewrite rule
- How can I dynamically generate an image with a static image URL?
- Rewrite custom post type URL parameters
- How to remove wordpress directory slash
- Changed pagination URLS to use p= instead of paged=
- Translate custom post type and taxonomy slug in URL?
- Right url for custom post type
- Preserve old website URL structure after migrating to WordPress
- Change pagination url format
- joomla to wordpress migration and 404 errors issues [closed]
- Rewriting “pretty” blog category URL with htaccess / add_rewrite_rule() causes 404 page
- Redirecting /px/?q=x to /px/x/
- URL redirect on updating the post date
- WordPress keeps writing rewrite rules to .htaccess
- mod-rewrite exception? keep #hash in matching urls?
- ow to change cutsom page url of wordpress site using htaccess
- custom wordpress rewrite
- Two sets of url one content?
- WordPress .htaccess ignore path and subsequent .htaccess files in subfolders
- Overwrite WordPress’s URL rewrite not working
- Rewriting a date hierarchy into a ‘yyyy-mm-dd’ slug
- Get logged in username in wordpress url
- URL problem: www.sitename.com/blog and www.sitename.com/learn using same WP installation
- custom url – add attachment’s id or name after post
- Rewrite rule that wp-login.php?action=register is left alone
- Make the home page’s slug visible in the browser’s URL bar
- dynamic URL rewrite
- Append a parametter at first or last to a certain URL
- Dynamic URL with rewrite rule not working
- How to Update / Change URL when Popup Modal Loads?
- Passing a variable to hyperlink text?
- Pretty URL via Rewrite
- Is it possible to rewrite a page URL from ID to name from an API?
- url redirect none www to www
- Rewrite URL for attachments
- Moved WordPress to Subdirectory, still hijacking requests to files outside of its directory
- How to add gallery slug to attachment url?
- How to remove Base URL Duplication?
- Rewrite URL query string for all pages
- Pagination appearing twice in URL after rewrite
- ModRewrite not working properly
- Simple URL rewriting gone wrong
- What is the proper way to use add_rewrite_rule to remove the (question mark)?
- WordPress post-type create url rewriting
- How can i maintain permalink structure and avoid a 404 error when loading external content?
- How to prevent URL-modification when page title contains digits only?
- How to redirect a virtual page (e.g. /blog) to the home page?
- How do I display a friendly URL link in the frontend?
- How to rename the WordPress wp-login.php running on IIS6?
- Please give me the rewrite rules for my ugly urls
- Rewrite Page Parameters