mod rewrite - .htaccess RewriteRule backreference order -


I have a question about the htaccess rewriting rule.

Is it possible to change this URL:

www.site.com/en/test

Something like this In:

www.site.com/test .php? I tried to use this revised rule

  RewriteRule ^ ([az] [az]) / (. *) $ $ 1 .php? Language = $ 2   

But the result of some online testing tools was the URL:

www.site.com/en.php?language= Test < / Em>

In advance thanks Matt

The reason for this confusion is that When you use contexts, the first reference to the match is always $ 1, the second is $ 2 and so on ) = First match, $ 1 (. * ) In the place "N":

It is only done by you, but only on parentheses:

  = second match, the location of "test" in $ 2   

so you need to reverse it in your output, like:

  RewriteRule ^ ([az] [ag]) / (. *) $ $ 2.php? Language = $ 1    

Comments