views:

29

answers:

2

Hi all, I have two problems in my current .htaccess. The script below works but has a limitation

RewriteRule ^products/([0-9])$ /products/$1/ [R]
RewriteRule ^products/([0-9])/$ /viewad.php?adid=$1

Limitation: if adid, is more than 10. it fails. I want it to have whatever number still there and work. my current solution was to add this everytime the id went higher than range.

RewriteRule ^products/([0-9][0-9])$ /products/$1/ [R]
RewriteRule ^products/([0-9][0-9])/$ /viewad.php?adid=$1 

Could some one refine or explain how to correct this rule to take numbers out of range.

Problem Two. Mapping multiple $_GET variables.

say i had a url like this

http://veepiz.com/africanews.php?app=view&func=viewcategory&categoryid=2&page=1

what rule would i write to have it in this format.

http://veepiz.com/africanews/category/2/page/1

or

http://veepiz.com/africanews/2/1

Thanx a lot for your time

+1  A: 

First problem:

RewriteRule ^products/([0-9]+)$ /products/$1/ [R]
RewriteRule ^products/([0-9]+)/$ /viewad.php?adid=$1

Or better yet:

RewriteRule ^products/(\d+)/?$ /viewad.php?adid=$1

Problem Two:

RewriteRule ^africanews/(\d+)/(\d+)$ /africanews.php?app=view&func=viewcategory&categoryid=$1&page=$2
aularon
thanx alot aularon. Any one have an answer for problem 2?
Sir Lojik
@aularon okay, the rule fails when i have a link witha trailing slash for problem 2. i have done this but it fails RewriteRule ^africanews/(\d+)/(\d+)$ /africanews/$1/$2/ [R]
Sir Lojik
A: 

Okay, i have fixed problem 2 with this thanx to aularon

RewriteRule ^africanews/(\d+)/(\d+)$ /africanews/$1/$2/ [R]
RewriteRule ^africanews/(\d+)/(\d+)/$ /africanews.php?app=view&func=viewcategory&categoryid=$1&page=$2
Sir Lojik