You must configure the redirect poddomen.site.ru/some-paht/ to site.ru/some-paht/?region=poddomen .

But so that if there is a parameter on the way, for example - poddomen.site.ru/some-paht/?parameters=param1 , redirect to site.ru/some-paht/?parameters=param1®ion=poddomen .

That is, the path and parameters after the domain name are not known in advance, you just need to save the entire path and parameters, only add to them as additional. subdomain name parameter.

    1 answer 1

    Here is an option in which even the name of the subdomain is unknown.

     RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(.+).site.ru$ RewriteRule (.*) http://site.ru/$1?region=%1 [L,R=301,QSA] 

    If you only need to redirect one subdomain, and do not touch the rest, the rules will change somewhat:

     RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^poddomen.site.ru$ [NC] RewriteRule (.*) http://site.ru/$1?region=poddomen [L,R=301,QSA] 

    I note that the QSA option is responsible for saving the parameters of a GET request.

    • thanks a lot, it works. - zemlia-zemlia