Results 1 to 2 of 2

Thread: Problem with Static URL generation

  1. #1
    Join Date
    Nov 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with Static URL generation

    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.

  2. #2
    Join Date
    Nov 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •