Urgent: mod_rewrite problem

Hi guys

I am new to using mod_rewrite, but need it for a project I am currently working on.

My problem is that I have one php file for searching that reacts differently with different number of parameters like category name, city name and state…
Now problem is that system cannot differentiate different parameters and always take first parameter as category name even it is city or state name

Simply saying I want to re-write URLs as.

domain-name/search.php?catname=abc as domain-name/abc.html

domain-name/search.php?catname=abc&city=efg as domain-name/abc-in-efg.html

domain-name/search.php?catname=abc&city=efg&state=xyz as domain-name/abc-in-efg-in-wyz.html

domain-name/search.php?city=efg as domain-name/efg.html

domain-name/search.php?state=xyz as domain-name/xyz.html

Please let me know if it is possible or I can adopt any better way to achieve this…

Hope someone can help me?



Sorry, it’s not possible BECAUSE Apache’s mod_rewrite cannot differentiate between your abc.html, efg.html and xyz.html, i.e., is it a catname, city name or state name? Okay, if you have a limited list of catnames and (UGH) there is a limited list of state names so you COULD list them in your regex like (AL|AK|AR|…) but that’s a terrible solution (IMHO). Of course, without more information about your search function, it’s difficult to make a good suggestion.

In my signature’s tutorial, I used city, state and country in my example (to develop regex) and you may get something out of that that you can use.

As for me, I’d suggest abc.cat, efg.city and xyz.st - or something like that so that you can differentiate your regex for these different mod_rewrite blocks.