Dynamic destinations

With dynamic destinations, a single redirect can send visitors to different destinations based on the incoming request: their country, the time of day, the device, a capture group in the path, or anything else we know about the request. Available from the Pro plan and up.

How it works

A redirect with dynamic destinations has multiple destinations, each with an expression. When a request comes in, we evaluate the expressions in order and use the first destination whose expression is true. A destination with an empty expression always matches, which makes it the fallback.

The order of the destinations matters: put the most specific expression first and the fallback last.

Parameters

Every destination variable is available as a parameter, without the curly braces:

domain.fqdn              www.redirect-me-plz.co.uk
domain.subdomain         www
path                     contact
country                  US
method                   POST
userAgent                Mozilla/5.0 (iPad; U; CPU..)
scheme                   https
acceptLanguage.language  nl

The domain.subdomain parameter is especially useful with wildcard subdomains. Capture groups from regex matching are available as $1, $2 and so on.

Functions

On top of the parameters, these functions are available for working with time. All times are UTC unless you pass a timezone as the second argument.

now()                                             the current time
time('15:00')                                     today at 15:00 UTC
time('15:00', 'Europe/Amsterdam')                 today at 15:00 Amsterdam time
datetime('2023-01-01')                            midnight UTC on that date
datetime('2023-01-01 15:00')                      that date and time, UTC
datetime('2023-01-01 15:00', 'Europe/Amsterdam')  that date and time, Amsterdam time

Compare them with the usual operators:

datetime('2023-01-01 15:00', 'America/New_York') > now()

Random traffic split

random(min, max) returns a random integer in that range for every request. To send 70% of the traffic to destination A and the rest to destination B, give A the expression:

random(1, 100) <= 70

and leave the expression of B empty. This is a simple way to A/B test landing pages or to migrate gradually. Follow the results in your analytics.

Expression language

Expressions are evaluated with the Go expr package. It supports comparison and boolean operators (==, !=, <, &&, ||, not), in for lists, and string operators such as contains, startsWith and matches. The language definition lists everything that's available.

Examples

Example 1: route by country

Source:         source.com
Destination 1:  https://destination.us     country == 'US'
Destination 2:  https://destination.com    (empty)

Visitors from the US are redirected to destination.us. Everyone else matches the empty expression and is redirected to destination.com.

Example 2: switch destinations at a launch date

Source:         source.com
Destination 1:  https://launching-soon.com   datetime('2023-01-01 12:00', 'America/New_York') > now()
Destination 2:  https://new-website.com      (empty)

Until January 1, 2023 at 12:00 New York time, visitors are redirected to launching-soon.com. After that moment, they're redirected to new-website.com.

Example 3: different destinations for morning and afternoon

Source:         source.com
Destination 1:  https://destination-before-12.com   now() < time('12:00')
Destination 2:  https://destination-after-12.com    (empty)

Before 12:00 UTC, visitors are redirected to destination-before-12.com; from 12:00 onwards to destination-after-12.com. Pass a timezone to time() to use local time instead.

Example 4: route by language

Source:         source.com
Destination 1:  https://example.nl    acceptLanguage.language == 'nl'
Destination 2:  https://example.de    acceptLanguage.language == 'de'
Destination 3:  https://example.com   (empty)

Dutch-speaking visitors go to example.nl, German-speaking visitors to example.de, and everyone else to example.com.

Related guides

More articles

Setup & Configuration
What are these DNS changes?
What DNS types can I use?
How long does the DNS change take?
Troubleshooting new redirects
Redirecting non-www to www
Redirect settings
Matching
Regex matching
Wildcard subdomains
Destination variables
Dynamic destinations
Redirect flattening
SSL profiles
robots.txt
Monitoring redirect.pizza itself
Features
Automatic HTTPS
Automatic DNS
Nameservers
Analytics
Broken destination monitoring
Email forwarding
Pause and resume
Dedicated IP
API
MCP
Zapier
Terraform provider
Security & Account
Team management
Two-factor authentication
SAML SSO
SSO via Okta
Summary email
HSTS (HTTP Strict Transport Security)
Prevent foreign embedding
Web Application Firewall (WAF)
Security & compliance
Subprocessors
Service level agreement (SLA)
Walkthroughs
GoDaddy: Forwarding with HTTPS support
Namecheap: Forwarding with HTTPS support
Cloudflare: Forwarding with HTTPS support
Network Solutions: Forwarding with HTTPS support
Hover: Forwarding with HTTPS support
Amazon Route 53: Forwarding with HTTPS support
Google Cloud DNS: Forwarding with HTTPS support
Azure DNS: Forwarding with HTTPS support
DigitalOcean: Forwarding with HTTPS support
NS1: Forwarding with HTTPS support
DNS Made Easy: Forwarding with HTTPS support
TransIP: Forwarding with HTTPS support
EuroDNS: Forwarding with HTTPS support
Mijndomein: Forwarding with HTTPS support
Freenom: Forwarding with HTTPS support

Domain redirects delivered hassle-free

Get started right away

  • Free plan
  • No creditcard required

redirect.pizza has all your favorite ingredients

Analytics

Who is still visiting those old domains? Gain valuable insight with detailed statistics and find out where the hits are coming from.

Learn more

API/MCP

Connect your software or AI clients to create redirects via our API and MCP. Automation makes your life easier.

Learn more

Destination Variables

You control how we handle your destination URL. Want to include your domain extension as a query string parameter? No problem.

Learn more

Dynamic destinations

Steer your traffic to different destinations, based on rules you define.

Learn more

Path forwarding

Keep the original path and keep it in the destination for a smooth domain migration and keeping your SEO game intact.

Learn more

Query Parameter Forwarding

Forward query parameters found on the source URL to the destination.

Learn more

Multiple Redirect Types

Choose the status code that works for you. Choose 301/307 (permanent), 302/308 (temporary) or frame your destination.

Learn more

Team management

Doing things all by yourself isn't much fun. Invite your co-workers to manage the redirects and work as a team.

Learn more

Automatic DNS

Integrate directly with your DNS provider, and apply the DNS changes from one platform.

Learn more

QR code generator

Create a QR code that you can use for marketing purposes. You can change the destination anytime after printing.

Learn more

Import & Export

Manage your redirects without losing precious time. Import and export redirects in our UX-friendly interface.

Global edge network

Redirecting in a blink of an eye; processing millions of request per hour in milliseconds.

Learn more

Broken destination monitor

Automatically checking your destinations to ensure it's reachable for everyone.

Learn more

Privacy First

We're based in Europe and are fully compliant with GDPR. Privacy-first!

Learn more

Wildcard subdomains

For when your domain utilizes a lot of different subdomains. Cover all subdomains with a single redirect.

Learn more

Tags

Group your redirects by adding tags. Keep everything organized and easy to find.

Bulk actions

Want to apply the same action for multiple redirects in one go? Do yourself a favor and start using bulk actions.

Dark mode

Give your eyes some well deserved rest by using the dark mode. Sync with your system or choose manually.

HSTS

Enable HSTS (HTTP Strict Transport Security) on team or domain level for an extra layer of protection.

Learn more

Change Destination Anytime

Once you're set up, you can change the destination URL anytime you want, and see the change in real-time.

Two-Factor Authentication

Secure your account with TOTP two-factor authentication. Scan the QR code, setup your app of choice, and you're safe(er).

Learn more

IDN Support

Add international hostnames with non-Latin characters. We ❤ that.

Support

Chat away! We're happy to help set up your account and answer your questions.