目录网站的Mod Rewrite

I have four files:

store.php -> as the listing for all products (paginated as ?pag={page number})

category-listing.php -> as the listing for category products,ex: ?catid=1 (also has pagination same as store.php)

subcategory-listing.php -> listing for subcategory products, ex: ?subcatid=1 (has pagination)

And the product detail page, product-detail.php -> will have product title and id

This is what i want:

www.mysite.com/store/ or www.mysite.com/store/?pag=2

www.mysite.com/store/category/ or www.mysite.com/store/category/?pag=2

www.mysite.com/store/subcategory/ or www.mysite.com/store/subcategory/?pag=2

www.mysite.com/store/a-product-detail-1 -> product detail (title and id)

Keep in mind the except the product detail all the other files are paginated as ?pag={pagenumber}

How can i do this?

This what i got so far for subcategories but pagination is not working

RewriteRule ^/store/%1? [R=302,L,NE]
RewriteCond %{THE_REQUEST} /subcategory\.php\?subcatid=([a-zA-Z0-9_-]+) [NC]
RewriteRule ^store/([a-zA-Z0-9_-]+)/?$ subcategory.php?subcatid=$1 [L,QSA,NC]