Rewrite URL to get rid of wp-content etc and change URL

$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

Help Code Review – I need to write on .htaccess file from theme’s function.php

The code below has work for me in the past 🙂 function add_to_htaccess( $rules ) { $content = <<<EOD # Enable Vary: Accept-Encoding Start <IfModule mod_headers.c> <FilesMatch “\.(js|css|xml|gz)$”> Header append Vary: Accept-Encoding </FilesMatch> </IfModule> EOD; return $content . $rules; } add_filter(‘mod_rewrite_rules’, ‘add_to_htaccess’);