Jump to content
  • 0

rewrite lang string in .htaccess to a virtual folder?


cluster

Question

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]

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...