Mod rewrite with 3 parameters ?

Posted by Axel on Stack Overflow See other posts from Stack Overflow or by Axel
Published on 2010-03-21T00:01:10Z Indexed on 2010/03/21 0:01 UTC
Read the original article Hit count: 355

Filed under:
|

Hello, I did tons of methods to figure out how to make this mod rewrite but i was completly unsuccessful.

I want a .htaccess code that rewrite in the following method:

http://www.mydomain.com/apple/upcoming/2 ---> http://www.mydomain.com/handler.php?topic=apple&orderby=upcoming&page=2

This is easy to do, but the problem is that all parameters are not required so the link has different levels of parameters each time like this:

http://www.mydomain.com/apple/popular/2 --> topic=apple&orderby=popular&page=2

http://www.mydomain.com/apple/2 --> topic=apple&orderby=&page=2

http://www.mydomain.com/all/popular/2 --> topic=all&orderby=popular&page=2

http://www.mydomain.com/apple/upcoming/ --> topic=apple&orderby=upcoming&page=

So briefly, the url has 3 optional parameters in one static order: (topic) (orderby) (page)

Note: the ORDERBY parameter can be "popular" or "upcoming" or nothing.

Thanks

© Stack Overflow or respective owner

Related posts about htaccess

Related posts about modrewrite