Answer the question
In order to leave comments, you need to log in
How to set language prefix in htaccess?
Hello everyone, please tell me how to set up htaccess so that if the url does not start with a language, then it will default to en. Here's what I googled, but it doesn't work for me.
RewriteCond %{REQUEST_URI} !(/(en|gr|ru)) [L]
RewriteRule ^(.*) /en/$1 [R=301,L]
Answer the question
In order to leave comments, you need to log in
I solved the problem myself, maybe there is something superfluous, but in general it works.
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /en/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} !^/(?:ru|en|gr)/
RewriteRule ^([^/]+(/.*)?)$ /en/$1 [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question