Answer the question
In order to leave comments, you need to log in
How to add an extra part to the url using .htaccess?
Hello!
There is a site domain.com
When you enter the site, the script for determining the country is triggered and adds two letters of the country to the url.
Let's say we came from Russia and then we get to domain.com/ru/
How to make the server perceive this address as domain.com/?lg=ru
?
Of course, any files/directories should be processed normally
. For example:
domain.com/ru/account/ -> domain.com/account/?lg=ru
domain.com/ru/php/1/order.php -> domain.com/php/1/order.php?lg=ru
domain.com/ru/account/ -> domain.com/account/?lg=ru
domain.com/ru/account -> domain.com/account/?lg=ru
Answer the question
In order to leave comments, you need to log in
Here's a starting example for you:
RewriteEngine On
RewriteRule ^([^/]+)(/.+)$ $2?lg=$1 [QSA,D]
RewriteRule ^(.+)$ index.php?p=$1 [QSA]
<?php
print_r($_REQUEST);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question