I have a rewrite rule I found in a old question of the American OS:
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*/)([^/]+)/([^/]+) $1?$2=$3&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^([^/]+)/ $1.php?%1 [L]
This rule makes it possible for me to pass any number of variables through the URL without having to make a rule for each quantity:
/mypage/param1/val1/param2/val2/param3/val3/... --->
/mypage.php?param1=val1¶m2=val2¶m3=val3&...
Notice that the first parameter passed turns the name of the php file, the others go two by two and see the parameter and value of a variable GET.
I want the first parameter to remain the file, but the second is the value of a variable that will always have the same name:
/test/foo/bar/baz/u/e/... --->
/test.php?varfixa=foo&bar=baz&u=e&...
I use regex and could even do this if it were just regex, but .htacces
has a few different things.
One way that can help me would also be to always send a index.php
, but with two fixed variables:
/test/foo/bar/baz/u/e/... --->
/index.php?varfixa1=test&varfixa2=foo&bar=baz&u=e&...