Forum Moderators: phranque
For example, this code converts a twelve-variable hyphen-delimited static URL beginning with "products" to its dynamic equivalent, calling "script.php" with variables named v1 through v12:
RewriteRule ^product([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-(.+)$ /script.php.$9?v1=$1&v2=$2&v3=$3&v4=$4&v5=$5&v6=$6&v7=$7&v8=$8 [C]
RewriteRule ^script\.php\.([^-]+)-([^-]+)-([^-]+)-([^-]+)-$ /script.php?val9=$1&v10=$2&v11=$3&v12=$4 [QSA,L]
You should be able to use five chained rules to handle 40 variables in a similar manner.
Jim
the original code
RewriteRule ^product([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-(.+)$ /script.php.$9?v1=$1&v2=$2&v3=$3&v4=$4&v5=$5&v6=$6&v7=$7&v8=$8 [C]
RewriteRule ^script\.php\.([^-]+)-([^-]+)-([^-]+)-([^-]+)-$ /script.php?[b]val9[/b]=$1&v10=$2&v11=$3&v12=$4 [QSA,L] the altered code
RewriteRule ^product([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-(.+)$ /script.php.$9?v1=$1&v2=$2&v3=$3&v4=$4&v5=$5&v6=$6&v7=$7&v8=$8 [C]
RewriteRule ^script\.php\.([^-]+)-([^-]+)-([^-]+)-([^-]+)[b]no dash[/b]$ /script.php?[b]v9[/b]=$1&v10=$2&v11=$3&v12=$4[b]&[/b] [QSA,L]
In order to make debugging this easier, you could temporarily change it to an external redirect so you can 'watch' it work. But you can only change the last rule to a 301 without interfering with the chained rule function.
Jim