Click to See Complete Forum and Search --> : apache mod rewrite


gnznroses
October 16th, 2005, 03:29 PM
i'm using mod reweite to get search engine friendly urls. i have these rules which turn this:
http://www.bashbargains.com/SearchIndex-Electronics_BrowseNameNode-Electronics.html
into this:
http://www.bashbargains.com/cgi-bin/shop_test.cgi?SearchIndex=Electronics&BrowseNameNode=Electronics



Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^(.+)-(.+)_(.+)-(.+)_(.+)-(.+)_(.+)-(.+)_(.+)-(.+)_(.+)-(.+)\.html$ /cgi-bin/shop_test.cgi?$1=$2&$3=$4&$5=$6&$7=$8&$9=$10&$11=$12
RewriteRule ^(.+)-(.+)_(.+)-(.+)_(.+)-(.+)_(.+)-(.+)_(.+)-(.+)\.html$ /cgi-bin/shop_test.cgi?$1=$2&$3=$4&$5=$6&$7=$8&$9=$10
RewriteRule ^(.+)-(.+)_(.+)-(.+)_(.+)-(.+)_(.+)-(.+)\.html$ /cgi-bin/shop_test.cgi?$1=$2&$3=$4&$5=$6&$7=$8
RewriteRule ^(.+)-(.+)_(.+)-(.+)_(.+)-(.+)\.html$ /cgi-bin/shop_test.cgi?$1=$2&$3=$4&$5=$6
RewriteRule ^(.+)-(.+)_(.+)-(.+)\.html$ /cgi-bin/shop_test.cgi?$1=$2&$3=$4
RewriteRule ^(.+)-(.+)\.html$ /cgi-bin/shop_test.cgi?$1=$2


ok, it works, except i want to also shorten the names of the paramaters, and these rules for some reason will not work:

# shorten param names
RewriteRule ^(.+)SI=(.+)$ $1SearchIndex=$2
RewriteRule ^(.+)BNN=(.+)$ $1BrowseNodeName=$2

i have my cgi script printing out the query string and it prints it out just with SI and BNN, not the expanded name. i don't understand why. tried several variations. i also tried puttin it at the beggining of the rule set, before the "-"s are turned into "="s, and using this:

RewriteRule ^(.+)SI-(.+)$ $1SearchIndex-$2
RewriteRule ^(.+)BNN-(.+)$ $1BrowseNodeName-$2


but ti still doesn't work...