url rewriting – Help with Rewrite Rule for Custom Post Type with Query String

I’m trying to get a custom rewrite working:

I’ve got the following URL pattern for a custom post type of ‘product’:


i’m trying to rewrite to:



Here’s what I’ve tried so far:

add_filter( 'query_vars', 'wp_query_vars' );
function wp_query_vars( $query_vars ){
    $query_vars() = 'type';
    return $query_vars;

add_action( 'init', 'init_custom_rewrite' );
function init_custom_rewrite() {

Any help would be great