I use a plugin for wordpress - qtranslate x. It seems all the rules, but when moving from one language to another redirects to the main page. This is due to the fact that the link is registered in the switch. For the Russian language - <a href="site.ru/ru" title="Русский (ru)">ru</a> And for the English language - <a href="site.ru/en" title="Английский(en)">en</a> It does not suit me. I want to do everything without redirect to home. Found in nete a function for wordpress that returns the path after the url <?php echo $_SERVER["REQUEST_URI"] ?>. But she returns it with the prefix of the language. I <a href="<?php echo "/ru".$_SERVER["REQUEST_URI"] ?>" title="Русский (ru)">ru</a> I made <a href="<?php echo "/ru".$_SERVER["REQUEST_URI"] ?>" title="Русский (ru)">ru</a> and it returns me site.ru/ru/ru . In general, how do I remove the language prefix from $_SERVER["REQUEST_URI"] . I am not strong in PHP. Approximately imagine that you need to push it into a variable to remove the prefix there and display it. But I don’t know how to do this specifically.

    1 answer 1

     $rest = substr("site.ru/ru/ru", 0, -3); 
    • Thanks, helped! - Skivs