Direct Answer
Destination URL variables are placeholders such as {host}, {host.domain}, {host.sub}, {path} and {qs} that you type into a redirect's destination. When a visitor arrives, RedirHub replaces each variable with the matching part of the incoming request, so a single redirect rule can send many hostnames, subdomains and paths to the right place.
A normal redirect always sends visitors to the same fixed URL. Variables make the destination dynamic: the destination is built from the hostname, path and query string of each request. This is useful when you move a domain and want to keep its paths, redirect many subdomains with one wildcard rule, or consolidate several old domains into one website.
Just keeping the path or query string?
You don't need variables for that. When you edit a redirect, turn on Path forwarding or Query forwarding under Forwarded Options.
Use variables when you need something the switches can't do, such as inserting the hostname or subdomain, or keeping the path when the destination already has its own query string.
Available variables#
| Variable | What it inserts | Example value |
|---|---|---|
| {host} | The full hostname that was requested | shop.example.co.uk |
| {host.domain} | The registered domain, without any subdomain | example.co.uk |
| {host.sub} | The subdomain part only (@ when there is no subdomain) | shop |
| {path} | The requested path, with a leading slash | /sale/shoes |
| {uri} | The requested path, without a leading slash | sale/shoes |
| {qs} | The query string, including ? or & (empty when there is none) | ?color=red |
| {random_string} | A random 6-character value (a–z, 0–9), new on every request | k3x9a1 |
A few details to keep in mind:
- Exact spelling: variables are lowercase and wrapped in curly braces. Anything RedirHub does not recognise, such as
{HOST}, is left in the URL as-is. - Multi-part domain endings:
{host.domain}correctly handles endings like .co.uk or .com.au. For a.b.example.com,{host.domain}is example.com and{host.sub}is a.b. - Bare domains: on a request to the root domain (example.com),
{host.sub}is @. - Trailing slashes:
{path}and{uri}drop trailing slashes, so /blog/ becomes /blog. On the homepage,{path}is / and{uri}is empty. - Query string connector:
{qs}adds ? when the destination has no query string yet, and & when it already does. If the request has no query string, it adds nothing.
Forwarding switches or variables?#
| What you want | Easiest way | Example |
|---|---|---|
| Keep the path | Path forwarding switch | a.com/one/two → b.com/one/two |
| Keep the query string | Query forwarding switch | a.com/?ref=chatgpt → b.com/?ref=chatgpt |
| Keep both | Turn on both switches | a.com/one?ref=x → b.com/one?ref=x |
| Keep the path when the destination has its own query string | {path} | b.com{path}?lang=en |
| Use the hostname, domain or subdomain | {host}, {host.domain}, {host.sub} | b.com/team/{host.sub} |
| Add a unique value to every visit | {random_string} | b.com/offer?ref={random_string} |
Variables and switches can be combined. For example, a destination with {host.sub} plus Path forwarding keeps both the subdomain and the path (see the examples below).
How to add a variable to a redirect#
- Open your redirect in the RedirHub dashboard, or create a new one.
- In the destination URL, type the variable where the value should go, for example
https://www.example.com/team/{host.sub}. - If you placed {path}, {uri} or {qs} in the destination yourself, turn off Path forwarding or Query forwarding for that redirect (see below).
- Save, then test a few real URLs, including the homepage. If something looks wrong, see Troubleshooting new redirects.
Examples#
Keep the path when the destination has its own query string#
textDestination: https://www.new-domain.com{path}?lang=en
old-domain.com/blog/hello → https://www.new-domain.com/blog/hello?lang=en
old-domain.com/ → https://www.new-domain.com/?lang=enPath forwarding always adds the path to the very end of the destination, which here would give https://www.new-domain.com/?lang=en/blog/hello. With {path} you decide where the path goes. If your destination has no query string, simply turn on Path forwarding instead.
Send each subdomain to its own page#
textSource: *.example.com
Destination: https://www.example.com/team/{host.sub}
alice.example.com → https://www.example.com/team/alice
bob.example.com → https://www.example.com/team/bobOne wildcard source covers every subdomain, and the variable decides where each one goes. Read more about wildcard subdomains, including plan availability and SSL.
Keep the subdomain, change the domain#
textSource: *.old-brand.com
Destination: https://{host.sub}.new-brand.com + Path forwarding on
shop.old-brand.com/cart → https://shop.new-brand.com/cart
docs.old-brand.com/api → https://docs.new-brand.com/apiWatch out
On the bare domain, {host.sub} is @, so old-brand.com/cart would become https://@.new-brand.com/cart.
Create a separate redirect for the root domain (old-brand.com) with the destination https://new-brand.com and Path forwarding turned on.
Consolidate many domains and see where visitors came from#
textDestination: https://www.new-brand.com/?from={host.domain}
old-brand.co.uk/ → https://www.new-brand.com/?from=old-brand.co.uk
shop.old-brand.de/sale → https://www.new-brand.com/?from=old-brand.deEvery old domain can use the same destination, and your analytics can still tell which domain each visitor typed.
Keep the query string#
textDestination: https://www.new-domain.com/landing?src=old + Query forwarding on
old-domain.com/?utm_source=mail → https://www.new-domain.com/landing?src=old&utm_source=mail
old-domain.com/ → https://www.new-domain.com/landing?src=oldYou don't need a variable for this. The Query forwarding switch adds the visitor's query string and picks ? or & for you, so campaign tracking stays intact. See also how to preserve UTM parameters through redirects.
Add a random value#
textDestination: https://www.example.com/offer?ref={random_string}
example.com/promo → https://www.example.com/offer?ref=4k9zq1 (different on every request)Variables and the forwarding switches#
The Path forwarding and Query forwarding switches use the same variables behind the scenes. Path forwarding adds /{uri} to the end of your destination, and Query forwarding adds {qs}. If you already placed {path}, {uri} or {qs} in the destination yourself, keep the matching switch turned off. Otherwise the value is added twice:
textDestination: https://www.new-domain.com{path} + Path forwarding on
old-domain.com/about → https://www.new-domain.com/about/aboutVariables only change where a visitor is sent. Which redirect handles a request is decided by RedirHub's matching rules.
Troubleshooting#
- The variable appears literally in the URL: check the spelling, lowercase letters and curly braces.
- A double slash appears (new-domain.com//about):
{path}already starts with a slash. Writehttps://new-domain.com{path}orhttps://new-domain.com/{uri}. - The path or query string is repeated: turn off Path forwarding or Query forwarding for that redirect.
- An @ appears in the hostname: the request was for the bare domain. Add a separate redirect for the root domain.
Frequently asked questions
No. Turn on Path forwarding or Query forwarding under Forwarded Options when you edit the redirect. Use variables only when you need something the switches can't do, such as inserting the hostname or subdomain, or keeping the path when the destination already has its own query string.
Yes. Variables must be written in lowercase inside curly braces, exactly as listed, for example {host.domain}. A variable RedirHub does not recognise, such as {HOST} or {domain}, is left in the destination unchanged.
Yes. You can combine as many variables as you need, and each one can appear more than once. For example, https://{host.sub}.new-brand.com{path}{qs} keeps the subdomain, the path and the query string.
Both insert the requested path without trailing slashes. {path} starts with a slash (/blog/hello), so put it directly after the domain. {uri} has no leading slash (blog/hello), so add the slash yourself: https://new-domain.com/{uri}.
{host.domain} understands multi-part domain endings. A request to shop.example.co.uk returns example.co.uk, and {host.sub} returns shop.
Yes. Variables are the easiest way to give every subdomain covered by a wildcard source such as *.example.com its own destination, for example https://www.example.com/team/{host.sub}.
