php - htaccess site/category/name/page error -


i have url in site pagination, this:

http://localhost/category/food/1  category = call category.php food = 1 category, may have name 1 = page number 

the problem is, maybe have page number, maybe not. if don't have page number want send page 1 php.

i tried:

rewriterule ^category/(.*) /category.php?categoria=$1 rewriterule ^category/(.*)/(.*) /category.php?categoria=$1&id=$1 

to sum up, want access page in 2 different ways:

http://localhost/category/food - in case send 1 php or http://localhost/category/food/1 

what wrong in code not working?

have rules this:

options -multiviews rewriteengine on  rewriterule ^category/([\w-]+)/(\d+)/?$ category.php?categoria=$1&id=$2 [l,qsa,nc]  rewriterule ^category/([\w-]+)/?$ category.php?categoria=$1&id=1 [l,qsa,nc] 

avoid using .* matches in regex.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -