# URL matching

The tours you create are only triggered when the user visits a page matching the URL you specify in the first step of a tour. HelpHero’s powerful URL matching engine allows you to match against dynamic URLs, different domains, wildcards and more.

## Matching a dynamic URL

URLs can often contain dynamic parts such as generated IDs, user names, categories, etc. We can introduce a **variable** to represent these dynamic segments of a URL.
For example:

```txt
/user/{user_id}/profile
```

Will successfully match all of the following URLs:

```txt ins="/user/3523/profile" ins="/user/2345/profile" ins="/user/6345/profile"
https://example.com/user/3523/profile
https://example.com/user/2345/profile
https://example.com/user/6345/profile
```

This variable will only match a single path segment ie the following URLs will not be matched

```txt del="/user/admin/2344/profile"
https://example.com/user/admin/2344/profile
```

## Matching the hash portion of URL

Some frontend frameworks such AngularJS use hash URLs for navigation. You can also use hashes for more advanced matching without having to use the JavaScript API. For example if you only wanted to show a tour for certain types of users you could change a link to include a special hash if a user is logged with a particular role.

```txt
/home#admin
```

Will successfully match the following URL:

```txt ins="/home#admin"
https://example.com/home#admin
```

But will not match:

```txt del="/home"
https://example.com/home
```

## Matching advanced

### Wildcards (*)

You can use a `*` modifier on a variable, to allow a variable to match zero or more path segments
For example:

```txt
/shop/{*any}
```

Will successfully match all of the following URLs:

```txt ins="/shop/" ins="/shop/checkout" ins="/shop/settings" ins="/shop/settings/currency"
https://example.com/shop/
https://example.com/shop/checkout
https://example.com/shop/settings
https://example.com/shop/settings/currency
```

But will not match:

```txt del="/other/settings"
https://example.com/other/settings
```

### One or more (+)

You can use a `+` modifier on a variable, to allow a variable to match one or more path segments
For example:

```txt
/shop/{+any}
```

Will successfully match all of the following URLs:

```txt ins="/shop/checkout" ins="/shop/settings" ins="/shop/settings/currency"
https://example.com/shop/checkout
https://example.com/shop/settings
https://example.com/shop/settings/currency
```

But will not match:

```txt del="/shop/"
https://example.com/shop/
```

### Optional (?)

You can use a `?` modifier on a variable, to specify that the path segment is optional
For example:

```txt
/settings/{?page}
```

Will successfully match both of the following URLs:

```txt ins="/settings" ins="/settings/currency"
https://example.com/settings
https://example.com/settings/currency
```

But will not match more than one segment:

```txt del="/settings/currency/edit"
https://example.com/settings/currency/edit
```

## Matching different domains

### Any domain

URL matchers starting with a **single slash** `/` will match against any domain.
For example:

```txt
/shop/checkout
```

Will successfully match all of the following URLs:

```txt ins="/shop/checkout"
https://example.com/shop/checkout
https://app.example.com/shop/checkout
https://mysite.com/shop/checkout
```

### Specific domain

URL matchers starting with a **double slash** `//` will match against specific domains.
For example:

```txt
//www.example.com/shop/checkout
```

Will only match the same domain:

```txt ins="//www.example.com/shop/checkout"
https://www.example.com/shop/checkout
```

But will not other domains:

```txt del="//app.example.com/shop/checkout" del="//mysite.com/shop/checkout"
https://app.example.com/shop/checkout
https://mysite.com/shop/checkout
```
