I am currently looking at creating a new type of site archive within WordPress that allows users to filter by category AND by year rather than the default category OR year. 

I am hoping to build a sidebar widget that creates the interface but I am looking for ideas and advice on creating the custom permalink setup. Ideally the archive will work with URLs along the lines of:

/category/year/

/category-1/year/

etc.

I have no requirement to filter any deeper than year. I have discovered [this snippet of code][1] but it does not work as expected.

Thanks

**UPDATE**

Following the suggestions of @StephenHarris I have developed the code a little further and come up with the following:

    add_action('generate_rewrite_rules', 'my_rewrite_rules');
    function my_rewrite_rules( $wp_rewrite ) {
    	
        // handles paged/pagination requests
    	$new_rules = array('news/(.+)/year/(.+)/page/?([2-9][0-9]*)' => '?category_name='.$wp_rewrite->preg_index(1).'&year='.$wp_rewrite->preg_index(2).'&paged='.$wp_rewrite->preg_index(3));

        // handles standard requests
    	$new_rules1 = array('news/(.+)/year/(.+)' => '?category_name='.$wp_rewrite->preg_index(1).'&year='.$wp_rewrite->preg_index(2));
    
    	// Add the new rewrite rule into the top of the global rules array
    	$wp_rewrite->rules = $new_rules + $new_rules1 + $wp_rewrite->rules;
    }

This allows a site to support URLS that look like:

/news/my-category/year/2011/page/2

as well as 

/news/my-category/year/2011

The posts/blog part of my site is prefixed by "news" so you may wish to tweak the first part of the regular expressions and remove the word "news".

If your going to use it make sure you flush your rewrite rules by visiting the permalinks settings page. 

Whilst writing this a new answer has just been posted by @Christopher Davies which I am also going to test.

  [1]: http://snipplr.com/view.php?codeview&id=17432