Jump to content
  • 0

rewrite lang string in .htaccess to a virtual folder?


Question

Posted

how can the lang string in the url be rewritten to point to a virtual folder and exclude the admin folder from rewrite?

https://www.mydomain.tld/?lang=en_us -> https://www.mydomain.tld/en/
https://www.mydomain.tld/?lang=fr_fr -> https://www.mydomain.tld/fr/
https://www.mydomain.tld/?lang=de_de -> https://www.mydomain.tld/de/

I've tried this but it doesn't work

RewriteRule ^en/(.*) /?lang=en_us/$1 [NC,L,QSA]
RewriteRule ^fr/(.*) /?lang=fr_fr/$1 [NC,L,QSA]
RewriteRule ^de/(.*) /?lang=de_de/$1 [NC,L,QSA]

also following doesn't work

# Force HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=307,NE,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php

RewriteCond %{REQUEST_URI} ^(.*)/install.php$
RewriteRule install.php %1/install/ [R=301,L]

RewriteCond %{QUERY_STRING} lang=en_us
RewriteCond %{QUERY_STRING} lang=de_de
RewriteCond %{QUERY_STRING} lang=fr_fr
# exclude all requests starting with /admin/
RewriteCond %{REQUEST_URI} !^/admin/.*$
RewriteRule ^(.*) /en/$1? [L,R=301]
RewriteRule ^(.*) /fr/$1? [L,R=301]
RewriteRule ^(.*) /de/$1? [L,R=301]

 

1 answer to this question

Recommended Posts

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...