URL rewrite in .htaccess file
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. 开发者_如何学Goit 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
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
This fixes problem 2 (thanks to aularon):
RewriteRule ^africanews/(\d+)/(\d+)$ /africanews/$1/$2/ [R]
RewriteRule ^africanews/(\d+)/(\d+)/$ /africanews.php?app=view&func=viewcategory&categoryid=$1&page=$2
精彩评论