There are links like:

www.site.ru/city123 www.site.ru/city123/type54/project1198 www.site.ru/project1198/type54/ 

In other words, the number of parameters (letters + numbers) can be arbitrary, and maybe not at all. This is the code that helps to get only the first pair of letter + numbers.

 RewriteRule ^([az]*)([0-9]*)/*$ index.php?$1=$2%{QUERY_STRING} 

At the exit I have:

 $_GET[city] => 123 

How in this case to get all GET parameters, if their number can be arbitrary or not be at all?

    1 answer 1

    Using .htaccess in this way, you can get only 4 parameters, since only 9 positions are allocated to the groups with feedback ($ 1 - $ 9) + $ 0 - the entire query string.

    Example

     RewriteEngine On RewriteRule ^([az]+)(\d+)/?$ index.php?$1=$2 [L,QSA] RewriteRule ^([az]+)(\d+)/([az]+)(\d+)/?$ index.php?$1=$2&$3=$4 [L,QSA] RewriteRule ^([az]+)(\d+)/([az]+)(\d+)/([az]+)(\d+)/?$ index.php?$1=$2&$3=$4&$5=$6 [L,QSA] RewriteRule ^([az]+)(\d+)/([az]+)(\d+)/([az]+)(\d+)/([az]+)(\d+)/?$ index.php?$1=$2&$3=$4&$5=$6&$7=$8 [L,QSA] 

    It would be more correct to redirect requests of this type to a router written in php, which will parse the query string and form variables based on it: