Rewrite rule to index.php in theme subfolder


I’m trying to create a rewrite to an index.php in a subfolder of my theme. But with this code I only end up on the front page:

function coupon_query_vars( $query_vars ){
$query_vars[] = 'gutschein';
return $query_vars;} 
add_filter('query_vars', 'coupon_query_vars');

function add_coupon_rewrite_rules($rules) {
$theme_name = next(explode('/themes/', get_stylesheet_directory()));

$newrules = array(
    '^gutschein-pdf/([^/]*)/?$' => 'wp-content/themes/'. $theme_name . '/pdf/?gutschein=$matches[1]',
$rules = $newrules + $rules;
return $rules;}
add_filter('rewrite_rules_array', 'add_coupon_rewrite_rules');

The nice url looks like:

And it should redirect to:

What do I have to change on the this rule?

HHGK 1 year 2022-11-25T10:38:14-05:00 0 Answers 0 views 0

Leave an answer