Hello, please help with the problem.

It is necessary that the label is opened as a subdomain, for example site.ru?tag=dom was available at dom.site.ru

server to work with subdomains configured.

function sd_category_rewrite_rules( $rules ) { $url = getenv( 'HTTP_HOST' );// для получения слага метки из урл dom.site.ru $domain = explode( ".", $url ); $categorystr = $domain[0]; // тут остается только dom $rules = array(); $rules['$'] = 'index.php?tag='.categorystr; return $rules; } add_filter( 'rewrite_rules_array', 'sd_category_rewrite_rules' ); 

That's why if you take the tag from the URL and transfer it to the $ categorystr variable, then nothing works. $ categorystr = $ domain [0]; // in this form, error 404

although if I myself point to the variable slug tags like this: $ categorystr = 'dom'; then everything works.

Tell me what could be the problem?

    1 answer 1

     'index.php?tag='.categorystr; 

    probably need:

     'index.php?tag='.$categorystr;