# URL Mapping

The URL Mapping feature is designed to redirect visitors from a 404 page in the destination store to an available page in the destination store. This will ensure a smooth transition from an unavailable page to an available page.

With **URL Mapping**, you can redirect users from an **Old Destination URL** to a **New Destination URL**.

**Example Scenario:**

You have two Shopify stores:

* **USA Store** → **geoip-country-redirect-demo.myshopify.com**
* **Canada Store** → **sg-local-app.myshopify.com**

A **Shirt** product exists in both stores. However, the **shirt in the Canadian store became unavailable**. Instead of users landing on a broken or unavailable page, you want to **redirect them to an alternative product page**.

**How URL Mapping Works:**

**If a user tries to visit:** \
Product URL in the USA store: **<https://geoip-country-redirect-demo.myshopify.com/products/shirt-1>**

Instead of being redirected to the same product URL in the Canadian store (**sg-local-app.myshopify.com/products/french-shirt-1**), they will be redirected to (**sg-local-app.myshopify.com/products/french-shirt-2)** (a new mapped URL in the app).

This ensures a smooth user experience by redirecting visitors to an **active and relevant product page** instead of a discontinued or unavailable one.

### Step 1: Click on Edit Rule → Advanced Settings

<figure><img src="/files/ITmfQmjs5Wk3Y1rH04v2" alt=""><figcaption></figcaption></figure>

### Step 2: Enable the URL Mapping option

Toggle to enable the URL Mapping feature

{% hint style="info" %}
Note: The [Relative redirect](/geoip-country-redirect/country-redirect/relative-redirect.md) setting should be enabled in the rule to utilise the URL Mapping functionality.
{% endhint %}

<figure><img src="/files/o2cjrKPeKKVpg2OA7pH8" alt=""><figcaption></figcaption></figure>

### Step 3: Enter path/URL in "Redirect From"

* &#x20;**Redirect From** – Enter the path/URL from which you want to redirect the visitors to the new destination URL.&#x20;
* **Type**:\
  **Exact** –Redirect users when the exact path is matched in the “Redirect from” field. It requires a complete URL to be added in the Redirect From field.\
  **Contains** – Redirect users when the contents added in the Redirect from’ field is detected. The **/path** is required to be added if the **Contains** type is selected.

Examples of Exact and Contains:

For **Exact** - add the URL  \[**sg-local-app.myshopify.com/products/french-shirt-1]**\
For **Contains** - add the path \[**/products/french-shirt-1]**

<figure><img src="/files/wqYfkBPXP4sSB7nZW0I1" alt=""><figcaption></figcaption></figure>

### Step 4: Enter the path/URL in the "Redirect To" field

**Redirect To** – Enter the New Destination URL on which you want to redirect visitors.&#x20;

* **Origin:** Add the required **/path** of the new page. This will redirect visitors to the new **Destination URL**.
* **Origin + Locale:** Add the **/path** and it will add locale to the path (if available)
* **Full URL:** add the complete URL of the New destination page.&#x20;

**Examples of the above options:**

**With Origin:** add the path **/products/french-shirt-2**\
**With Origin + Locale:** add the path **/products/french-shirt-2.** This will add the language locale to the URL **en/products/french-shirt-2**\
**With Full URL:** add the complete **URL - <https://sg-local-app.myshopify.com/products/french-shirt-2>**

<figure><img src="/files/5pv3w6hOdcUIDQTVY4AC" alt=""><figcaption></figcaption></figure>

### Step 5: Click on Save to apply the changes

<figure><img src="/files/ooIXIpPAAaOqr7B6Ft2k" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**In case of any queries, please feel free to reach us at** [**help@spicegems.com**](mailto:help@spicegems.com)
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.spicegems.com/geoip-country-redirect/country-redirect/url-mapping.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
