custom permalinks for custom post type

Hello

i have custom post type: book
taxonomy: booktype
i created: ebook as parent category of comedy, both are created from booktype taxomony

so i need the permalink structure like this:

domain.com/book/ebook/comedy/bookname

I used custompress + custom post permalink but it doesn't work

If i check ebook and comedy categories, url works like this
domain.com/book/ebook/bookname
and if i dont check ebook category.
domain.com/book/ebook/comedy/bookname. 404 error

How to solve this? i want to keep ebook and comedy checked without 404 error

thanks