<p>Your issue is that the <code>@web</code> alias resolves to this:</p>

<blockquote>
  <p>The URL to the folder that contains the <strong>index.php</strong> file that was loaded for the request</p>
</blockquote>

<p>Now that you’re serving your English site from web/en/index.php, <code>@web</code> will already resolve to <a href="http://website.test/en" rel="nofollow noreferrer">http://website.test/en</a>.</p>

<p>The alias <code>@web/en</code> you are using for your site’s base URL does therefore resolve to <a href="http://website.test/en/en" rel="nofollow noreferrer">http://website.test/en/en</a></p>

<p>So you can fix it be using <code>@web</code> for your base URLs, or what I would rather recommend is to serve all your sites from a single web/index.php file (which is possible <a href="https://github.com/craftcms/cms/commit/8e78482" rel="nofollow noreferrer">now in Craft 3</a>). With this change <code>@web</code> will always refer to <a href="http://website.test" rel="nofollow noreferrer">http://website.test</a> and you need to use <code>@web/en</code> again in your site settings.</p>

CC BY-SA 3.0
2018-04-27T10:41:07.317Z
Just a simple question: we usually do that too and I usually recommend others the same because it's the most easiest solution in my opinion. Do you know any disadvantages in having a single `index.php` for all requests rather than having multiple different one?
Robin Schambach
CC BY-SA 3.0
2018-04-27T10:51:35.730Z
@RobinSchambach none that I know of, but I don’t have much experience with it either. I can update my answer when I encounter a situation where dedicated index.php files are needed. But the [auto detection](https://github.com/craftcms/cms/commit/8e78482) seems to work really well!
carlcs
CC BY-SA 3.0
2018-04-27T10:32:38.640Z
2018-04-27T10:32:38.640Z
carlcs
<h1>Problem</h1>

<p>I have a problem on a local Valet setup: the locale URL segment is appearing twice in URLs.</p>

<p>Eg from a page at URL of <code>en/about/approach</code>, <code>{{ url('about/approach')}}</code> outputs <code>https://website.test/en/en/about/approach</code></p>

<p>(And you only get the correct URL if outputting this from <code>/about/approach</code>)</p>

<p>Guessing I've missed something obvious but no idea what... thanks!</p>

<hr>

<h1>Setup</h1>

<p>Base URLs are set to <code>@web/en/</code> and <code>@web/de/</code>.</p>

<p>In the <code>web</code> folder we have two index files, eg <code>de/index.php</code> and <code>en/index.php</code> </p>

<p>Running <code>valet which</code> reports <code>This site is served by [CraftValetDriver].</code></p>

<p>In <code>general.php</code> I've got:</p>

<pre><code>'test' =&gt; [
// Base site URL
'siteUrl' =&gt; 'http://website.test'
</code></pre>

<p>The Entry URI Format for the Pages section is <code>{parent.slug}/{slug}</code></p>

<hr>

<h1>Contents of /web/en/index.php:</h1>

<pre><code>&lt;?php
/**
 * Craft www bootstrap file
 */

// Set path constants
define('CRAFT_BASE_PATH', dirname(__DIR__, 2));
define('CRAFT_SITE', 'english');
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'/vendor');

$root = dirname(__DIR__).'/en';

// Load Composer's autoloader
require_once CRAFT_VENDOR_PATH.'/autoload.php';

// Load dotenv?
if (file_exists(CRAFT_BASE_PATH.'/.env')) {
    (new Dotenv\Dotenv(CRAFT_BASE_PATH))-&gt;load();
}

// Load and run Craft
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
$app-&gt;run();
</code></pre>

<hr>

<h1>Contents of /web/index.php:</h1>

<pre><code>&lt;?php
/**
 * Craft web bootstrap file
 */

// Set path constants
define('CRAFT_BASE_PATH', dirname(__DIR__));
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'/vendor');

// Load Composer's autoloader
require_once CRAFT_VENDOR_PATH.'/autoload.php';

// Load dotenv?
if (file_exists(CRAFT_BASE_PATH.'/.env')) {
    (new Dotenv\Dotenv(CRAFT_BASE_PATH))-&gt;load();
}

// Load and run Craft
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
$app-&gt;run();
</code></pre>

<localization><craft3><multi-site><segments>
Locale URL segment being duplicated, eg https://website.test/en/en/
# Locale URL segment being duplicated, eg https://website.test/en/en/

(Asked by: username_0 on 2018-04-27)

Problem
I have a problem on a local Valet setup: the locale URL segment is appearing twice in URLs.
Eg from a page at URL of en/about/approach, {{ url('about/approach')}} outputs https://website.test/en/en/about/approach
(And you only get the correct URL if outputting this from /about/approach)
Guessing I've missed something obvious but no idea what... thanks!

Setup
Base URLs are set to @web/en/ and @web/de/.
In the web folder we have two index files, eg de/index.php and en/index.php 
Running valet which reports This site is served by [CraftValetDriver].
In general.php I've got:
'test' => [
// Base site URL
'siteUrl' => 'http://website.test'

The Entry URI Format for the Pages section is {parent.slug}/{slug}

Contents of /web/en/index.php:
load();
}

// Load and run Craft
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
$app->run();


Contents of /web/index.php:
load();
}

// Load and run Craft
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
$app->run();

**Tags:** localization, craft3, multi-site, segments

---

## 1 answers

### Answer by username_1 on 2018-04-27. Score: 3

Your issue is that the `@web` alias resolves to this:

> The URL to the folder that contains the **index.php** file that was loaded for the request

Now that you’re serving your English site from web/en/index.php, `@web` will already resolve to <http://website.test/en>.

The alias `@web/en` you are using for your site’s base URL does therefore resolve to <http://website.test/en/en>

So you can fix it be using `@web` for your base URLs, or what I would rather recommend is to serve all your sites from a single web/index.php file (which is possible [now in Craft 3](https://github.com/craftcms/cms/commit/8e78482)). With this change `@web` will always refer to <http://website.test> and you need to use `@web/en` again in your site settings.

> **Comments:**
> **username_2**: Just a simple question: we usually do that too and I usually recommend others the same because it's the most easiest solution in my opinion. Do you know any disadvantages in having a single `index.php` for all requests rather than having multiple different one?  
> **username_1**: @RobinSchambach none that I know of, but I don’t have much experience with it either. I can update my answer when I encounter a situation where dedicated index.php files are needed. But the [auto detection](https://github.com/craftcms/cms/commit/8e78482) seems to work really well!  

---

