Set up a flexible pattern URL redirect
Last updated: March 1, 2022
Flexible redirects dynamically update URLs that have a certain structure, while keeping certain parts of the original URL structure intact. In the URL redirects tool, you can define the components that you want to add to the destination URL.
Create a flexible pattern URL redirect
- In your HubSpot account, click the settings settings icon in the main navigation bar.
- In the left sidebar menu, navigate to Website > Domains & URLs.
- Click the URL Redirects tab.
- Click Add URL redirect.
- In the right panel, select the Flexible redirect type.
- Enter your Original URL and Redirect to URL:
- To define a component part of a URL, use a colon : followed by a name for that variable in the origin URL.
- To add that component to your destination URL add the same name wrapped in curly brackets { }.
- Each piece of the URL path between the forward slashes of each subdirectory / / must have its own component to include it as a variable in the destination URL. The one exception to this rule is that you can add the entire end of a URL (up until the query string) as a single component using the star symbol * followed by a name for the rest of the URL. Any non-component text in the destination URL will not be dynamically replaced.
- Click More options to customize the redirect or add a note.
- Click Add URL redirect.
Please note: it is not recommended to create flexible redirects for URLs with a period in the URL path.
Examples of flexible pattern URL redirects
Keeping individual components from original URL
If your original URL structure contained a common pattern such as a date that you wanted to include in the destination URL, you could use a flexible URL redirect.
Example URL: http://www.example.com/2012/12/30/my-first-post
Original URL: http://www.example.com/:year/:month/:day/:post-name
Redirect to: http://blog.example.com/{month}/{day}/{year}/{post-name}
After saving this flexible redirect, the example URL would redirect to: http://blog.example.com/12/30/2012/my-first-post.
Defining the end of the URL as a component
Sometimes you may want to make the entire end (up until a query string) of a URL one component.
Example URL: http://www.example.com/product-id/22/jet-ski
Original URL : http://www.example.com/product-id/*rest-of-url
Redirect to: http://info.example.com/products/{rest-of-url}
After saving this flexible redirect, the example URL would redirect to: http://info.example.com/products/22/jet-ski.
Using both individual components and the rest of the URL
Example URL: http://www.example.com/blog/12/25/2013/marketing/merry-christmas?post-id=33
Original URL: http://www.example.com/blog/:month/:day/:year/*rest-of-url?post-id=:post-id
Redirect to: http://blog.example.com/{month}-{day}-{year}/post-{post-id}/{rest-of-url}.
After saving this flexible redirect, the example original URL would redirect to: http://blog.example.com/12-25-2013/post-33/marketing/merry-christmas.
Thank you for your feedback, it means a lot to us.
Related content
-
Update your DNS records
When you connect your domain to HubSpot, you'll need to update the DNS records in your DNS provider. Below...
Knowledge Base -
Connect your domain to HubSpot
Connect your website domain to HubSpot to publish your content on HubSpot-hosted website, landing, or blog...
Knowledge Base -
Understand subscription limits for domains
Each domain you connect to HubSpot consists of a subdomain, brand domain, and top-level domain. The number...
Knowledge Base