Log in

View Full Version : Problem with Static URL generation



LakkadBabu
11-07-2009, 06:59 AM
Hi everyone,
I am submitting a form using Get method which is generating following URL:

http://www.mydomain.com/abc/compare_prod.php?compare[]=68&compare[]=66&compare[]=67

where compare array can have maximum of 5 values.

I want my URl look like this

http://www.mydomain.com/abc/compare-68-and-66-and-67

I have tried to write following code in my .htaccess file (which is placed under the abc directory and other mod-rewrite rules are working fine.)

following is the code I wrote in .htaccess file:
RewriteRule ^compare-(.*)-and-(.*)-and-(.*)-and-(.*)-and-(.*)$ /compare_prod.php?compare1=$1&compare2=$2&compare3=$3&compare4=$4&compare5=$5

I don't know how to deal arrays in mod-rewite rules.
Please Help.

LakkadBabu
11-10-2009, 06:09 AM
Hi every one I got the solution to my problem

you need to type the following rewrite rules to the .htaccess file

RewriteRule ^compare-([0-9]+)-and-([0-9]+)$ compare.php?compare[]=$1&compare[]=$2
RewriteRule ^compare-([0-9]+)-and-([0-9]+)-and-([0-9]+)$ compare.php?compare[]=$1&compare[]=$2&compare[]=$3
RewriteRule ^compare-([0-9]+)-and-([0-9]+)-and-([0-9]+)-and-([0-9]+)$ compare.php?compare[]=$1&compare[]=$2&compare[]=$3&compare[]=$4
RewriteRule ^compare-([0-9]+)-and-([0-9]+)-and-([0-9]+)-and-([0-9]+)-and-([0-9]+)$ compare.php?compare[]=$1&compare[]=$2&compare[]=$3&compare[]=$4&compare[]=$5