<p>The request segments will come back as an array, where each part between slashes will be an array element so <code>mysite.com/first/second/third</code> gives segments <code>[first,second,third]</code> </p>

<p>If you're just looking for the first segment, you can try
<code>(craft.app.request.segments|first == 'uk')</code>
to get that information.</p>

CC BY-SA 4.0
2020-06-11T14:05:57.663Z
Unfortunately this doesn't work.
HeyImArt
CC BY-SA 4.0
2020-06-11T18:27:55.547Z
That should work. With ``devMode`` on, when you do a ``{{ dump(craft.app.request.segments) }}`` what are you getting?
RitterKnight
CC BY-SA 4.0
2020-06-11T12:26:42.087Z
2020-06-11T12:26:42.087Z
Greg Bowne
<p>Assuming you're using Craft's <a href="https://docs.craftcms.com/v3/sites.html" rel="nofollow noreferrer">multi-site functionality</a>(?), you'll want to use something like <code>{{ currentSite.handle }}</code> to check which site they're on. For multiple sites configured to use sub-directories from a single domain name, the first segment of the URL is considered to be part of the <code>siteUrl</code> and will not be returned in the segments array.</p>

CC BY-SA 4.0
2020-06-11T13:14:40.217Z
2020-06-11T13:14:40.217Z
James Smith
<p>I'm trying to declare if a user is on a /uk or /us version of the site.</p>

<p>domain.com/uk/
domain.com/us/</p>

<pre><code>{% if (craft.app.request.segments == '/uk/') %}
UK site
{% endif %}
</code></pre>

<p>This doesnt work. Can anyone explain why and where I'm going wrong?</p>

<p>Thank you</p>

<segments><getsegment>
Request Segment URL
# Request Segment URL

(Asked by: username_0 on 2020-06-11)

I'm trying to declare if a user is on a /uk or /us version of the site.
domain.com/uk/
domain.com/us/
{% if (craft.app.request.segments == '/uk/') %}
UK site
{% endif %}

This doesnt work. Can anyone explain why and where I'm going wrong?
Thank you

**Tags:** segments, getsegment

---

## 2 answers

### Answer by username_1 on 2020-06-11. Score: 2

The request segments will come back as an array, where each part between slashes will be an array element so `mysite.com/first/second/third` gives segments `[first,second,third]`

If you're just looking for the first segment, you can try
`(craft.app.request.segments|first == 'uk')`
to get that information.

> **Comments:**
> **username_0**: Unfortunately this doesn't work.  
> **username_2**: That should work. With ``devMode`` on, when you do a ``{{ dump(craft.app.request.segments) }}`` what are you getting?  

---

### Answer by username_3 on 2020-06-11. Score: 2

Assuming you're using Craft's [multi-site functionality](https://docs.craftcms.com/v3/sites.html)(?), you'll want to use something like `{{ currentSite.handle }}` to check which site they're on. For multiple sites configured to use sub-directories from a single domain name, the first segment of the URL is considered to be part of the `siteUrl` and will not be returned in the segments array.


---

