Apache pseudo-static rewrite matching parameters more than 10 processing methods

  
                  

We know that rewrite can only be defined to $9 in pseudo-static. If it is over, it will be invalid. In actual use, when there are more than 9 parameters, how can we solve it? See below for decomposition.

RewriteRule backreference, reference method is: $N (0 <= N <= 9) reference the current (with several RewriteRule instructions) RewriteCond matching Pattern component (parentheses) !). RewriteCond backreference, the reference method is: %N (1 <= N <= 9) refers to the grouping component in the last matching condition in the current RewriteCond condition (parentheses!)

Fish is not as good as giving people a fish. Let's demonstrate the process of implementation.

First of all, you have to have an environment, support pseudo-static, and then test. Create a new web folder named 1 and create a php document named: index.php The document code is as follows: <?PHP echo $_GET['a'].'<br>'; echo $_GET[' b'].'<br>'; echo $_GET['c'].'<br>'; echo $_GET['d'].'<br>'; echo $_GET['e' ].'<br>'; echo $_GET['f'].'<br>'; echo $_GET['g'].'<br>'; echo $_GET['h']. '<br>'; echo $_GET['i'].'<br>'; echo $_GET['j'].'<br>'; echo $_GET['k'].'< ;br>'; echo $_GET['l'].'<br>'; echo $_GET['m'].'<br>'; echo $_GET['n'].'<br> ;'; ?> Copy the code This php to implement the url pass parameters, an, 14 parameters, more than 9

Then write the .htaccess file RewriteEngine On RewriteRule ^a (.*) b (. *)c(.*)d(.*)e(.*)f(.*)g(.*)h(.*)$ $8&a=$1&b=$2&c=$3& ;d=$4&e=$5&f=$6&g=$7 [C,NC] RewriteRule ^(.*)i(.*)j(.*)k(.*)l(.*) m(.*)n(.*)$ index.php?$8&h=$1&i=$2&j=$3&k=$4&l=$5&m=$6&n= $7 [QSA,L,NC]

RewriteRule ^index-(.*?)-(.*?)-(.*?)-(.*?)-(.*?)- (.*?)-(.*?)-(.*?)-(.*?).html$ $9&a=$1&b=$2&c=$3&d=$4&e =$5&f=$6&g=$7&h=$8 [C,NC] RewriteRule ^(.*?)-(.*?)-(.*?)-(.*?)-(. *?)-(.*?)$ index.php?$7&i=$1&j=$2&k=$3&l=$4&m=$5&n=$6 [QSA,L, NC] Copy the code Here I wrote two ways to make it easy for everyone to use

1.http://127.0.0.1/1/a1b2c3d4e5f6g7h8i9j10k11l12m13n14 2. http://127.0.0.1/1/index- 1-2-3-4-5-6-7-8-9-10-11-12-13-14.html

If you run the above address, a number of 1-14 will appear, indicating you The configuration was successful

Copyright © Windows knowledge All Rights Reserved