Rewrite Rule for Custom Page with Query Vars in URL

I manually deleted the .htaccess file and regenerated, which along with the code below, made the rewrite work. The second rewrite rule in the code below makes the pagination work properly.

The .htaccess file doesn’t seem to be getting written with any rules though, but the rewrite is working now anyhow.

function listen_rewrite_action() {
  add_rewrite_tag('%show%','([^/]*)');
  add_rewrite_rule(
    '^listen/([^/]+)$',
    'index.php?pagename=listen&show=$matches[1]',
    'top');
  add_rewrite_rule(
    '^listen/([^/]+)/page/([^/]+)$',
    'index.php?pagename=listen&show=$matches[1]&paged=$matches[2]',
    'top');
}
add_action( 'init', 'listen_rewrite_action' );

Leave a Comment

error code: 523