Answers.Body: <p>It looks like you forgot to setup <code>siteUrl</code> in config/general.php for your sites.</p>
  
  <pre><code>'siteUrl' =&gt; [
      'landing' =&gt; 'https://www.mycompany.com/international',
      'sales-en' =&gt; 'https://www.mycompany.com/sales/en',
      'sales-fr' =&gt; 'https://www.mycompany.com/sales/fr',
      ...
  ],
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-25T16:20:44.413Z
Answers.Text: Thank you, now international links look like `www.mycompany.com/international/my-slug`. But I'm facing another issue: each of these URLs (including international homepage) returns a 404 Template not found error. It looks like it try ot load templates of an `international/` subfolder that doesn't exists. Do you know how can I fix this without using Routing?
Answers.UserDisplayName: Romain P.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-26T09:47:30.553Z
Answers.Text: No, templates/international/index.html should not be required as it falls back to templates/index.html if you rely on template path routing. If you do set an entry template in the section settings, you can point to whatever template you want for each site individually.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-26T11:16:13.313Z
Answers.Text: It makes sense... On the `Single` > `Homepage`, Site Settings `URI` is set to blank (`Leave blank if this is the homepage`) and template is set to same file for each Site. Homepage template is found for each Site, except for `/international` which is set as Primary and that Craft can't find (404 error). Its sounds like a bug that I should report, no?
Answers.UserDisplayName: Romain P.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-26T18:13:38.280Z
Answers.Text: Sorry but I can’t say that. 404 can be a lot, server configs etc.?!
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-26T20:49:01.623Z
Answers.Text: Thank you, I contacted the Craft Support for further assistance.
Answers.UserDisplayName: Romain P.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-30T09:05:00.213Z
Answers.Text: This was a `CRAFT_SITE` issue. `CRAFT_SITE` wasn't set there: `htdocs/index.php` & `htdocs/international/index.php`. I thought it was set automatically because this Site was set as Primary. Thank you Brad for pointing it out!
Answers.UserDisplayName: Romain P.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-25T16:07:59.340Z
Answers.LastActivityDate: 2018-01-25T16:07:59.340Z
Answers.UserDisplayName: carlcs
Body: <p>I have a main domain, <code>www.mycompany.com</code>, which has several groups of sites, which are available in several languages:</p>
  
  <pre><code>www.mycompany.com/international
  
  www.mycompany.com/sales/en
  www.mycompany.com/sales/fr
  
  www.mycompany.com/customers/en
  www.mycompany.com/customers/fr
  
  etc.
  </code></pre>
  
  <p>Once visitor access to <code>www.mycompany.com</code>, he will be auto-redirected to a Site version depending on his IP (probably using a third-party plugin like <a href="https://superbig.co/plugins/country-redirect" rel="nofollow noreferrer">Country Redirect</a>, once <a href="https://craftcms.stackexchange.com/a/23438/131">available for Craft 3</a>).</p>
  
  <p>The problem is that when I set up the Sites, Craft force to set a primary Site. So I choose the <code>www.mycompany.com/international</code> version.</p>
  
  <p>But when Site is saved, the Base URL is displayed as <code>www.mycompany.com</code> instead of <code>www.mycompany.com/international</code>, and all URLs in this one are now like <code>www.mycompany.com/my-slug</code> instead of <code>www.mycompany.com/international/my-slug</code>.</p>
  
  <p>This probably can be solved by pre-checking all links, adding the slug inside the URL if current Site id is the <code>www.mycompany.com/international</code> version, then adding a routing rule for all <code>/international/*</code> requests.</p>
  
  <p>But it sounds a bit tricky in the some cases, so I wondered if there was a cleaner way to achieve this?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-25T14:06:47.840Z
Comments.Text: Did you set siteUrl in config/general.php for your sites?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-25T14:53:56.553Z
Comments.Text: Whoops... `siteUrl` was set to `((isset($_SERVER['HTTPS'])) ? 'https://' : 'http://').$_SERVER['HTTP_HOST']` instead of an array of `site handle` => `site base URL`. Thank you!
Comments.UserDisplayName: Romain P.
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-25T16:57:37.323Z
Comments.Text: Would you mind sharing your solution as an official answer @RomainPoirier? Might end up helping someone in the future.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-26T08:53:33.160Z
Comments.Text: Of course, thank you for asking this. carlcs has posted his answer, I'm just waiting for further help, because I'm still facing errors with template / routing after setting the siteUrl. I didn't find out how to fix this without having to write weird routing rules.
Comments.UserDisplayName: Romain P.
Tags: <localization><url><craft3><routes><multi-site>
Title: Craft 3 with Multi-Site: how to not set a primary site, or add a first segment to all primary site URLs?
ThreadText: # Craft 3 with Multi-Site: how to not set a primary site, or add a first segment to all primary site URLs?
  
  (Asked by: username_0 on 2018-01-25)
  
  I have a main domain, `www.mycompany.com`, which has several groups of sites, which are available in several languages:
  
  ```
  www.mycompany.com/international
  
  www.mycompany.com/sales/en
  www.mycompany.com/sales/fr
  
  www.mycompany.com/customers/en
  www.mycompany.com/customers/fr
  
  etc.
  
  ```
  
  Once visitor access to `www.mycompany.com`, he will be auto-redirected to a Site version depending on his IP (probably using a third-party plugin like [Country Redirect](https://superbig.co/plugins/country-redirect), once [available for Craft 3](https://craftcms.stackexchange.com/a/23438/131)).
  
  The problem is that when I set up the Sites, Craft force to set a primary Site. So I choose the `www.mycompany.com/international` version.
  
  But when Site is saved, the Base URL is displayed as `www.mycompany.com` instead of `www.mycompany.com/international`, and all URLs in this one are now like `www.mycompany.com/my-slug` instead of `www.mycompany.com/international/my-slug`.
  
  This probably can be solved by pre-checking all links, adding the slug inside the URL if current Site id is the `www.mycompany.com/international` version, then adding a routing rule for all `/international/*` requests.
  
  But it sounds a bit tricky in the some cases, so I wondered if there was a cleaner way to achieve this?
  
  **Tags:** localization, url, craft3, routes, multi-site
  
  > **Comments:**
  > **username_1**: Did you set siteUrl in config/general.php for your sites?  
  > **username_0**: Whoops... `siteUrl` was set to `((isset($_SERVER['HTTPS'])) ? 'https://' : 'http://').$_SERVER['HTTP_HOST']` instead of an array of `site handle` => `site base URL`. Thank you!  
  > **username_2**: Would you mind sharing your solution as an official answer @RomainPoirier? Might end up helping someone in the future.  
  > **username_0**: Of course, thank you for asking this. username_1 has posted his answer, I'm just waiting for further help, because I'm still facing errors with template / routing after setting the siteUrl. I didn't find out how to fix this without having to write weird routing rules.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-01-25. Score: 1 | Accepted answer
  
  It looks like you forgot to setup `siteUrl` in config/general.php for your sites.
  
  ```
  'siteUrl' => [
      'landing' => 'https://www.mycompany.com/international',
      'sales-en' => 'https://www.mycompany.com/sales/en',
      'sales-fr' => 'https://www.mycompany.com/sales/fr',
      ...
  ],
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you, now international links look like `www.mycompany.com/international/my-slug`. But I'm facing another issue: each of these URLs (including international homepage) returns a 404 Template not found error. It looks like it try ot load templates of an `international/` subfolder that doesn't exists. Do you know how can I fix this without using Routing?  
  > **username_1**: No, templates/international/index.html should not be required as it falls back to templates/index.html if you rely on template path routing. If you do set an entry template in the section settings, you can point to whatever template you want for each site individually.  
  > **username_0**: It makes sense... On the `Single` > `Homepage`, Site Settings `URI` is set to blank (`Leave blank if this is the homepage`) and template is set to same file for each Site. Homepage template is found for each Site, except for `/international` which is set as Primary and that Craft can't find (404 error). Its sounds like a bug that I should report, no?  
  > **username_1**: Sorry but I can’t say that. 404 can be a lot, server configs etc.?!  
  > **username_0**: Thank you, I contacted the Craft Support for further assistance.  
  > **username_0**: This was a `CRAFT_SITE` issue. `CRAFT_SITE` wasn't set there: `htdocs/index.php` & `htdocs/international/index.php`. I thought it was set automatically because this Site was set as Primary. Thank you username_2 for pointing it out!  
  
  ---
  
  