Is it possible to change one segment of the current url and keep the rest of it the same in a cleaner way? How would you go about changing one segment of the current url? I have a select in the footer that you can click on a country name and then it redirects you to the homepage of that country version of the website. 

&lt;!-- language: lang-twig --&gt;
&lt;form action="" name="dropdown"&gt;
    &lt;select name="country-select"  id="country-select" class="form-control" onchange="location = this.value;" autocomplete="off"&gt;&gt;
        {% set locales = craft.i18n.getSiteLocaleIds() %}
        {% set locale = craft.locale %}
        {% for loc in locales %}
            {# checking if current loop has active locale #}
            {% set isHome = (loc == locale) %}
            {% if isHome %}

                {% if loc == "en" %}
                    &lt;option value="/{{ loc | replace({'en': 'eu'}) }}" selected&gt;Europe&lt;/option&gt;   

                    {% set myJs %}

                        var currentCountryLocale = "Europe";
                        var currentCountryLocale = "{{ loc | replace({'en': 'eu'}) | trim('_') }}";

                    {% endset %}

                    {% includeJs myJs %}

                {% else %}
                    {% set subTags = locale|split('_') %}
                    {% set territory = subTags|length &gt; 1 ? craft.i18n.getLocaleData(craft.locale).getTerritory(subTags|last) : '' %}  
                        &lt;option value="/{{ loc | replace({'en': ''}) | trim('_') }}" selected&gt;{% if territory %}{{ territory }}{% endif %}&lt;/option&gt;  

                    {% set myJs %}

                        var currentCountryName = "{{ territory }}";
                        var currentCountryLocale = "{{ loc | replace({'en': ''}) | trim('_') }}";


                    {% endset %}

                    {% includeJs myJs %}

                {% endif %}

            {% else %}

                {% if loc == "en" %}
                    &lt;option value="/{{ loc | replace({'en': 'eu'}) }}"&gt;EU&lt;/option&gt;   
                {% else %}
                    &lt;option value="/{{ loc | replace({'en': ''}) | trim('_') }}"&gt;{{ loc | replace({'en': ''}) | trim('_') | upper }} &lt;/option&gt;   
                {% endif %}

            {% endif %}

        {% endfor %}
    &lt;/select&gt;
&lt;/form&gt;


I have been trying to figure out how to switch only the country/region part of the url, which is segment(2), but all of my experiments so far have been extremely complicated and confusing and I haven't found a good solution yet. Am I missing something? There must be a more efficient way to accomplish this, as it's probably not a good idea to wrap conditionals inside of conditionals inside of more conditionals. 

I also have the added complexity of needing to include a continent (Europe) as one of the versions of the website, for which I'm using the "en" locale, as you can see in the bit of code above.
So!!!! I was getting confused about the various craft properties pertaining to urls, and I thought that even if I grab the path, that it would include the region segment, but surprise! {{ craft.request.path }} grabs the remaining portion of the url, after the region segment! So, I can use code that I've written above and I only need to add:

&lt;!-- language: lang-twig --&gt;

    /{{ craft.request.path }}


Example: 

&lt;!-- language: lang-twig --&gt;

    &lt;form action="" name="dropdown"&gt;
        &lt;select name="country-select"  id="country-select" class="form-control" onchange="location = this.value;" autocomplete="off"&gt;&gt;
            {% set locales = craft.i18n.getSiteLocaleIds() %}
            {% set locale = craft.locale %}
            {% for loc in locales %}
                {# checking if current loop has active locale #}
                {% set isHome = (loc == locale) %}
                {% if isHome %}

                    {% if loc == "en" %}
                        &lt;option value="/{{ loc | replace({'en': 'eu'}) }}/{{ craft.request.path }}" selected&gt;Europe&lt;/option&gt;   

                    {% else %}
                        {% set subTags = locale|split('_') %}
                        {% set territory = subTags|length &gt; 1 ? craft.i18n.getLocaleData(craft.locale).getTerritory(subTags|last) : '' %}  
                            &lt;option value="/{{ loc | replace({'en': ''}) | trim('_') }}/{{ craft.request.path }}" selected&gt;{% if territory %}{{ territory }}{% endif %}&lt;/option&gt;  

                    {% endif %}

                {% else %}

                    {% if loc == "en" %}
                        &lt;option value="/{{ loc | replace({'en': 'eu'}) }}/{{ craft.request.path }}"&gt;EU&lt;/option&gt;   
                    {% else %}
                        &lt;option value="/{{ loc | replace({'en': ''}) | trim('_') }}/{{ craft.request.path }}"&gt;{{ loc | replace({'en': ''}) | trim('_') | upper }} &lt;/option&gt;   
                    {% endif %}

                {% endif %}

            {% endfor %}
        &lt;/select&gt;
    &lt;/form&gt;


Yay!! I wanted to share my answer because I've been working on this issue for a few days and couldn't find a solution anywhere. Maybe it will help someone else that runs into this issue when building a multi-country website with Craft. Cheers!