Skip to content

Set up a flexible pattern URL redirect

Last updated: June 28, 2023

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

Marketing Hub Professional, Enterprise
CMS Hub Starter, Professional, Enterprise

Flexible pattern URL redirects allow you to redirect one URL to multiple others with a single mapping. For example, you can redirect an entire blog without needing to create URL mappings for each blog post. 

Create a flexible pattern URL redirect

  • In the left sidebar menu, click Website Domains & URLs.
  • Click the URL Redirects tab.
  • In the top right, click Add URL.
  • In the right panel, select the Flexible redirect type. 
add-flexible-url-redirect
  • In the Original URL field, enter the flexible pattern URL for the pages you will be redirecting from
  • In the Redirect to field, enter the flexible pattern URL for the pages you will be redirecting to.
  • Click More options to customize the redirect or add a note.
  • 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

There are several ways to set up a flexible pattern URL redirect:

  • Redirect the entire end of the URL:
    • You can redirect the entire end of the URL using *rest-of-URL in the original URL and {rest-of-URL} in the redirect URL. For example, if you want to redirect a blog to a new subdomain: 
    • Example original URL 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 components:
    • A component is each piece of the URL after a forward slash (/). For example, in the URL www.example.com/2022/03/26/my-first-post, there are four components: 2022, 03, 26 and my-first-post). 
    • When setting up a redirect, each component is defined by a colon (:), followed by the name for that variable in the original URL. For example, the URL http://www.example.com/2022/03/26/my-first-post will be set up as http://www.example.com/:year/:month/:day/:post-name.
    • Add the same variable name wrapped in curly brackets ( {} ) in the redirect URL. Using the previous example, the URL will look like http://www.example.com/{year}/{month}/{day}/{post-name}.
    • Example original URL 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 a specific query parameter to another page
    • A query parameter is a string of text added to the end of a URL after a question mark (?). It is generally used to provide additional information about how a visitor accessed a page. 
    • You can set up a redirect that brings all users visiting a page with a particular query parameter to another page. If you are setting up redirects with query parameters, you must turn on the option to Match query strings in the More options dropdown menu. 
    • Example original URL 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 individual components and the rest of the URL:
    • You can also create complex URL redirects using both components and the rest of the URL.
    • Example original URL Desired redirect url
      http://www.example.com/blog/12/25/2013/marketing/merry-christmas?post-id=33 http://blog.example.com/12-25-2013/post-33/marketing/merry-christmas
         
      "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.