Skip to content

Set up a flexible pattern URL redirect

Last updated: February 10, 2026

Available with any of the following subscriptions, except where noted:

Flexible pattern URL redirects route multiple URLs to new destinations using a single redirect rule. This approach is useful during large site changes, such as migrating a blog, restructuring URLs, or moving content to a new subdomain. 

Permissions required URL Redirects permission is required to set up URL redirects.

Create a flexible pattern URL redirect

Flexible pattern URL redirects use variables and patterns to match parts of a URL and pass them through to the destination URL.

  1. In your HubSpot account, click the settings settings icon in the top navigation bar.
  2. In the left sidebar menu, click Content Domains & URLs.
  3. Click the URL Redirects tab.
  4. In the top right, click Add URL redirect.
  5. In the right panel, select the Flexible redirect type.
  1. In the Original URL field, enter the flexible pattern URL for the pages being redirected from.
  2. In the Redirect to field, enter the flexible pattern URL for the destination pages.
  3. To customize advanced settings or add a note, click More options.
  4. Click Add URL redirect.

Please note: it is not recommended to create a URL mapping for URLs with a period in them.

Examples of flexible pattern URL redirects

The following examples illustrate common ways to configure flexible pattern URL redirects.

Redirect the entire end of a URL

Use this pattern to redirect all content under a specific path while keeping the rest of the URL. 

This method uses:

  • *rest-of-url in the original URL.
  • {rest-of-url} in the redirect URL.

For example, if you want to redirect a blog to a new subdomain:

Original URL (example) Desired Redirect URL
http://www.example.com/posts/my-first-post http://blog.example.com/posts/my-first-post
Original URL field Redirect to field
http://www.example.com/posts/*rest-of-url http://blog.example.com/posts/{rest-of-url}

Set up individual URL components

A component is each segment of a URL separated by a forward slash (/). 

For example, the URL www.example.com/2022/03/26/my-first-post contains the following components:

  • 2022
  • 03
  • 26
  • my-first-post

When creating a flexible redirect, define each component using a colon (:) in the original URL, then reference the same variables in the redirect URL using curly brackets ({...}).

Original URL (example) Desired Redirect URL
http://www.example.com/2022/03/26/my-first-post http://blog.example.com/03/26/2022/my-first-post
Original URL field Redirect to field
http://www.example.com/:year/:month/:day /:post-name http://blog.example.com/{month}/{day}/{year}/{post-name}

Redirect based on a query parameter

Query parameters appear after a question mark (?) in a URL and offer more context, such as campaign or promotion details. Flexible pattern URL redirects can route traffic based on specific query parameter values. 

When configuring redirects that include query parameters, turn on Match query strings in the More options section. 

Original URL (example) Desired Redirect URL
http://www.example.com/certification?promo_code=12345 http://www.example.com/enrollment?promo_code=12345
Original URL field Redirect to field
http://www.example.com/certification?promo_code=:promocode http://www.example.com/enrollment?promo_code={promocode}

Use a combination of components and the rest of the URL

More complex redirects can combine individual components with the rest of the URL. This approach is useful when both structured URL segments and query parameters need to be kept.

Original URL (example) Desired Redirect URL
http://www.example.com/blog/12/25/2013/ marketing/halloween?post-id=13 http://blog.example.com/12-25-2013/post-13/marketing/halloween
Original URL field Redirect to field
http://www.example.com/blog/:month/:day/ :year/*rest-of-url?post-id=:post-id http://blog.example.com/{month}-{day}-{year}/post-{post-id}/{rest-of-url}
Was this article helpful?
This form is used for documentation feedback only. Learn how to get help with HubSpot.