flexible rewrite ‘ramble’ URLs with WordPress

You shouldn’t use the htaccess instead you should use the WordPress APIs

e.g.

function custom_rewrite( $wp_rewrite ) {

    $feed_rules = array(
        'archives/(\d+)(?:/.*)+'    =>  'index.php?p='. $wp_rewrite->preg_index(1)
);

    // ( array merge must be done this way, to ensure new rule comes first )
    $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
}
// refresh/flush permalinks in the dashboard if this is changed in any way
add_filter( 'generate_rewrite_rules', 'custom_rewrite' );

Leave a Comment