Hi everyboy,
Oflate I faced great difficulty to pass additional parameters in mod_rewrite urls. I'll tell it from the beginning to help you understand exactly what was the problem. I have urls in my webpages which are like this one:
CODE
http://www.mydomainname.com/index.php?category=category_name

And I wanted the url to look like this ( a more search engine friendly form):
CODE
http://www.mydomainname.com/category/category_name.htm

So I applied mod_rewrite rule as per usual practice.

CODE
RewriteEngine On
RewriteRule ^category/([^/\.]+).htm$ index.php?category=$1& [L]


In my earlier post in a similar topic here , I have made it clear what these notaions stand for. Here is the link to my previous post.

Now when I require to pass an additional parameter like :

CODE
http://www.mydomainname.com/index.php?category=category_name&country=country_name


I found it was not that all easy.
I got some idea about how to accomplish that in a post at doriat.com but it did not work for me. So I had to try for something different.
Finally, I passed the additional parameter with the mod_rewrite url in this way:

CODE
http://www.mydomainname.com/category_name|country_name.htm


without making any change in the aforesaid RewriteRule.
And used

CODE
$qry_string=$_GET["category"];


to retrieve the value stored there.

Then I exploded the $qry_string variable to seperate the stored value into two parts.

CODE
$qry_string_exploded=explode("|",$qry_string);


And finally I retrieved the values like

CODE
$category= $qry_string_exploded[0];
$country=$qry_string_exploded[1];



I think, this is a simple solution to pass additional query strings in mod_rewrite urls.
Regards,
Sid

 

 

 


Comment/Reply (w/o sign-up)