D
D
DJDiM2021-10-12 19:57:42
htaccess
DJDiM, 2021-10-12 19:57:42

How to make a redirect in .htaccess from the language to the main one without changing the rest of the site structure?

There is a multilingual site. The main language is Russian, but all pages must be written for languages ​​like site.com/ru/katalog.html If you click Russian on the main page, the line will change from site.com to site.com/ru/ . That is a double, both addresses work. If I use the Redirect 301 /ru/ https://site.com construct in .htaccess , then all pages are also redirected, site.com/katalog.html is obtained , and the page does not open. I tried different options for .htaccess, but nothing happened. How to do this redirect?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2021-10-13
@DJDiM

I tried to understand for a very long time what you were trying to say.
In general, everything can be done. A
special case should be located above the general one, just do not forget about the possibility of negation with the sign!
RewriteRule ^ru/katalog\.html$ /? [L,R=301]
this rule redirects the ru directory to a slash
RewriteRule ^ru/$ /? [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question