M
M
Medvedoc2019-05-27 11:25:29
htaccess
Medvedoc, 2019-05-27 11:25:29

How to do htaccess correctly?

there is a multilingual script, but there the links are obtained like:
domain.ru/index.php?lang=en
domain.ru/index.php?lang=hi
domain.ru/index.php?lang=de
how can I get
domain links in the output .ru/en
domain.ru/hi
domain.ru/de

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valery, 2019-05-27
@Desay

RewriteEngine On
RewriteRule ^([a-zA-Z]*)?$ /index.php?lang=$1 [L,QSA]

V
Viktor Taran, 2019-05-27
@shambler81

You have a get parameter and it redirects like this

RewriteCond %{QUERY_STRING} (^|&)lang\=en($|&)
RewriteRule ^index\.php$ /en? [L,R=301]

Well, if you make it dynamic then
RewriteCond %{QUERY_STRING} (^|&)lang\=(.+)($|&)
RewriteRule ^index\.php$ /%2? [L,R=301]

where 2 is the second group from kveri
, it can also be facilitated, is this the general form if he will not be this get? f &
if you are sure that it will be the first, then it can be shorter
RewriteCond %{QUERY_STRING} lang\=(.+)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question