Answers.Body: <p>I'm not exactly sure what you are trying to achieve, but here is a way to have unlimited locales with only a single subfolder in your public root directory.</p>
  
  <ol>
  <li><p>Put all of your locale subfolders into a single folder, called <code>locales</code> for example. So your directory structure would be:</p>
  
  <pre><code>public/locales/de/
  public/locales/es/
  public/locales/fr/
  </code></pre></li>
  <li><p>Make sure you update the craft path in each locale's <code>index.php</code> file accordingly:</p>
  
  <pre><code>$craftPath = '../../../craft';
  </code></pre></li>
  <li><p>Then you just need the following code in your root <code>.htaccess</code> file to redirect to the appropriate subfolder:</p>
  
  <pre><code># Redirect locales
  RewriteCond %{REQUEST_URI} ^/(de|es|fr)/ [NC]
  RewriteRule (.+) /locales/$1 [QSA,L]
  </code></pre></li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-31T07:44:25.800Z
Answers.Text: Drats. This folder arrangement sounded great, but didn't work for me. I moved the language folders (en|th|zh) into a /locales/ directory, changed $craftPath in each index.php, modified the .htaccess file with this code (changed to reflect the relevant language codes) — but it didn't work. I just get a "The requested URL was not found on this server" error. As far as I know the rewrite engine is working fine. Any idea what might be going wrong here?
Answers.UserDisplayName: Andrew Macpherson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-31T22:33:25.697Z
Answers.Text: can you post your code somewhere so i can review it?
Answers.UserDisplayName: Ben Croker
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-27T19:41:49.133Z
Answers.LastActivityDate: 2015-01-27T19:41:49.133Z
Answers.UserDisplayName: Ben Croker
Body: <p>Would it be possible to have a cleaner site setup without all those 'locale' subfolders in the webroot? Somehow it looks like there's something similar already done here (<a href="https://github.com/craftcms/cms/tree/master-v2/src/services/HttpRequestService.php#L99" rel="nofollow noreferrer">https://github.com/craftcms/cms/tree/master-v2/src/services/HttpRequestService.php#L99</a>) if I'm not wrong, wouldn't it be nicer to also just remove the locale if one is detected?</p>
  
  <p>Bonus question :) :
  Where in the hell is the actual Entry Slug -> Template resolving done? I know there's a lot of stuff happening with filters, action and resource requests. The closest I could get is that here the template/render controller gets triggered (<a href="https://github.com/craftcms/cms/tree/master-v2/src/framework/web/CWebApplication.php#L274" rel="nofollow noreferrer">https://github.com/craftcms/cms/tree/master-v2/src/framework/web/CWebApplication.php#L274</a>) which in the end resolves to the action render method in the TemplatesController (<a href="https://github.com/craftcms/cms/tree/master-v2/src/controllers/TemplatesController.php#L50" rel="nofollow noreferrer">https://github.com/craftcms/cms/tree/master-v2/src/controllers/TemplatesController.php#L50</a>), already with the correct $template parameter set. </p>
  
  <p>Could someone guide me in a direction here? </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-27T15:53:02.757Z
Comments.Text: You linked us to the `init` function... what are we supposed to be looking at? Confused.
Comments.UserDisplayName: Douglas McDonald
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-27T15:58:41.017Z
Comments.Text: What's the problem with `/webroot/en/index.php` being responsible for `http://example.com/en`? And why should the folder (incl. `index.php`) be removed, if the locale is detected?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-27T16:25:40.777Z
Comments.Text: ah sorry, I meant to link to line 130 where they shift the _segments array to remove the 'admin' part of the url. I think something similar could be done with the locales.
  
  And I don't want to remove the folder, I want to shift the _segments array to remove the locale-segment from the url and set the current craft locale. Like that there would be no need to just copy paste the index.php in several different folders.
Comments.UserDisplayName: Sidney Widmer
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-27T17:21:23.870Z
Comments.Text: I think it's not so much *multiple locale subfolders in the webroot* as it is multiple webroots.
Comments.UserDisplayName: Marion Newlevant
Tags: <localization><multi-environment><routing>
Title: Multi-lingual site without subfolders
ThreadText: # Multi-lingual site without subfolders
  
  (Asked by: username_0 on 2015-01-27)
  
  Would it be possible to have a cleaner site setup without all those 'locale' subfolders in the webroot? Somehow it looks like there's something similar already done here (<https://github.com/craftcms/cms/tree/master-v2/src/services/HttpRequestService.php#L99>) if I'm not wrong, wouldn't it be nicer to also just remove the locale if one is detected?
  
  Bonus question :) :
  Where in the hell is the actual Entry Slug -> Template resolving done? I know there's a lot of stuff happening with filters, action and resource requests. The closest I could get is that here the template/render controller gets triggered (<https://github.com/craftcms/cms/tree/master-v2/src/framework/web/CWebApplication.php#L274>) which in the end resolves to the action render method in the TemplatesController (<https://github.com/craftcms/cms/tree/master-v2/src/controllers/TemplatesController.php#L50>), already with the correct $template parameter set.
  
  Could someone guide me in a direction here?
  
  **Tags:** localization, multi-environment, routing
  
  > **Comments:**
  > **username_1**: You linked us to the `init` function... what are we supposed to be looking at? Confused.  
  > **username_2**: What's the problem with `/webroot/en/index.php` being responsible for `http://example.com/en`? And why should the folder (incl. `index.php`) be removed, if the locale is detected?  
  > **username_0**: ah sorry, I meant to link to line 130 where they shift the _segments array to remove the 'admin' part of the url. I think something similar could be done with the locales.  And I don't want to remove the folder, I want to shift the _segments array to remove the locale-segment from the url and set the current craft locale. Like that there would be no need to just copy paste the index.php in several different folders.  
  > **username_3**: I think it's not so much *multiple locale subfolders in the webroot* as it is multiple webroots.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_4 on 2015-01-27. Score: 2
  
  I'm not exactly sure what you are trying to achieve, but here is a way to have unlimited locales with only a single subfolder in your public root directory.
  
  1. Put all of your locale subfolders into a single folder, called `locales` for example. So your directory structure would be:
  
     ```
     public/locales/de/
     public/locales/es/
     public/locales/fr/
  
     ```
  2. Make sure you update the craft path in each locale's `index.php` file accordingly:
  
     ```
     $craftPath = '../../../craft';
  
     ```
  3. Then you just need the following code in your root `.htaccess` file to redirect to the appropriate subfolder:
  
     ```
     # Redirect locales
     RewriteCond %{REQUEST_URI} ^/(de|es|fr)/ [NC]
     RewriteRule (.+) /locales/$1 [QSA,L]
  
     ```
  
  > **Comments:**
  > **username_5**: Drats. This folder arrangement sounded great, but didn't work for me. I moved the language folders (en|th|zh) into a /locales/ directory, changed $craftPath in each index.php, modified the .htaccess file with this code (changed to reflect the relevant language codes) — but it didn't work. I just get a "The requested URL was not found on this server" error. As far as I know the rewrite engine is working fine. Any idea what might be going wrong here?  
  > **username_4**: can you post your code somewhere so i can review it?  
  
  ---
  
  