I want to 开发者_如何学JAVAuse static URLs on my site, so when a user goes to
http://www.domain.com/toys/ - he will see the toys category page
and when he goes to
http://www.domain.com/toys/playing-cards - he will see the product page
I am having some trouble with the following rewrite rule:
RewriteRule ^item/(toys|clothes)/(.*)/?$ showPRODUCT.php?id=$2 [NC,L]
RewriteRule ^item/(toys|clothes)/?$ showCATEGORY.php?product=$1 [NC,L]
because the first rule "catches" the category URL (http://www.domain.com/toys/) in addition to the product (and vice versa if I switch the order).
Any ideas?
Thanks!!
David
RewriteRule ^item/(toys|clothes)/(.*)/?$ showPRODUCT.php?id=$2 [NC,L]
RewriteRule ^item/(toys|clothes)/?$ showCATEGORY.php?product=$1 [NC,L]
Assuming the "^item" at the beginning is supposed to be there...
What you need is to change the * repeater to a + repeater, that way it won't match the category. Likewise, the L flag should stop it from continuing with the other rewriterule if it finds the first one:
RewriteRule ^item/(toys|clothes)/(.+)/?$ showPRODUCT.php?id=$2 [NC,L]
RewriteRule ^item/(toys|clothes)/?$ showCATEGORY.php?product=$1 [NC,L]
精彩评论