How can you make permalink work for custom post type and taxonomy?

I have spent days now trying to figure this out, StackOverflow is my last resort. All I want is the following:

http://www.mydomain.com/my-post-stype/my-top-level-category/my-sub-level-category/my-page.html

For posts this is insane easy, just adding /%category%/%postname%.html as a permalink does the trick. However for custom post type this seems insane tough.

I have a registered post_type project. And a taxonomy project_category

Now I like my permalinks to turn out as

/project - Overview of projects in all categories.
/project/CATEGORY - Overview of projects within that category.
/project/CATEGORY/SUBCATEGORY - Overview of projects within that subcategory.
/project/CATEGORY/SUBCATEGORY/postname - The actual post.

Probably wp_rewrite needs to help me out here tho I have no clue how. Can anyone help me out?

Solutions Collecting From Web of "How can you make permalink work for custom post type and taxonomy?"

I’ve just gotten my head around Doing something similar. This is adapted from this tutorial

  1. For your post type registration make sure that query_var, publicly_queryable, and has_archive are set to true and rewrite is set to false.
  2. Next up is the code here.

Edit: sorry, but code hinting is completely not working for me today. Code is in above link