0

i'm struggling with a modrewrite/htaccess problem (using php). i'm running a multi-language web which has urls like www.mydomain.com/en/index.php "en" will translate as &lang=en

now i'm looking for a way to always force english as default language for ANY url- eg. if a user tries accessing an url like www.mydomain.com/dashboard.php, it should automatically translate to www.mydomain.com/en/dashboard.php

any ideas how to solve this? thanks

Fuxi
  • 329
  • 2
  • 6
  • 15
  • Do you want to redirect `/en/dashboard.php` if access? Or without redirect as if translated? – Bora Jul 25 '13 at 10:10
  • Hi, I edited my answer to your previous question http://stackoverflow.com/questions/16854820/htaccess-rule-for-language-detection – Paolo Stefan Jul 25 '13 at 10:16

1 Answers1

1

Assuming you have a list of languages your site supports:

RewriteCond %{REQUEST_URI} !^/(en|fr|es|de)/
RewriteRule ^(.*)$ en/$1 [R]

This will rewrite the url if it doesn't start with either /en/, /fr/, /es/ or /de/.

Sumurai8
  • 20,333
  • 11
  • 66
  • 100
  • looks nice, but when calling the root url (eg. mydomain.com) it causes an endless loop .. :/ – Fuxi Jul 25 '13 at 12:33
  • That is not the cause of this rule. This rule will rewrite `mydomain.com` to `mydomain.com/en/` and then this rule will not match anymore. Find out what rule is conflicting and alter that. In the worst case scenario change `RewriteRule ^(.*)$ en/$1` to `RewriteRule ^(.+)$ en/$1`. – Sumurai8 Jul 25 '13 at 12:39