CMS Development

TwoM
Participant

flexible pattern URL mapping .html site to COS

SOLVE

Is there a way to use one redirect to re-direct all of the old .html pages to Hubspot COS pages.

Something like this old page

redirect
https://www.mysite.com/about.html 
with this code 
https://www.mysite.com/{rest of url}.html

redirect to my new hubspot page
https://www.mysite.com/{rest of url}

 I am trying to avoid a bunch of page level redirects from the old .html pages to the new Hubspot COS pages

 

0 Upvotes
1 Accepted solution
JasonRosa
Solution
HubSpot Employee
HubSpot Employee

flexible pattern URL mapping .html site to COS

SOLVE

Hey @TwoM this is something I was able to accomplish recently for a project I was working on. I'm sure you've already come across this article. There are two types of components you can add into your flexible URL mappings. One is the * asterisk character and the other is the : colon character. The * asterisk character creates a component that goes all the way until the very end of the URL, which in your case would include the html at the end of the URL which we wouldn't want. The : colon character, on the other hand, creates a named component that is matched until the next delimiter character (./=&?). So in your scenario, you can accomplish this with a few different redirects (you'd need to set up one for each subdirectory that you have on your site). Example: 

 

Original URL: /:item.html

Redirected To: /{item}

* would work for URLs with the pattern of www.test.com/test.html > www.test.com/test

 

Original URL: /:item/:item2.html

Redirected To: /{item}/{item2}

*would work for URLs with the pattern of www.test.com/test/test.html > www.test.com/test/test

 

Original URL: /:item/:item2/:item3.html

Redirected To: /{item}/{item2}/{item3}

*would work for URLs with the pattern of www.test.com/test/test/test.html > www.test.com/test/test/test

 

View solution in original post

1 Reply 1
JasonRosa
Solution
HubSpot Employee
HubSpot Employee

flexible pattern URL mapping .html site to COS

SOLVE

Hey @TwoM this is something I was able to accomplish recently for a project I was working on. I'm sure you've already come across this article. There are two types of components you can add into your flexible URL mappings. One is the * asterisk character and the other is the : colon character. The * asterisk character creates a component that goes all the way until the very end of the URL, which in your case would include the html at the end of the URL which we wouldn't want. The : colon character, on the other hand, creates a named component that is matched until the next delimiter character (./=&?). So in your scenario, you can accomplish this with a few different redirects (you'd need to set up one for each subdirectory that you have on your site). Example: 

 

Original URL: /:item.html

Redirected To: /{item}

* would work for URLs with the pattern of www.test.com/test.html > www.test.com/test

 

Original URL: /:item/:item2.html

Redirected To: /{item}/{item2}

*would work for URLs with the pattern of www.test.com/test/test.html > www.test.com/test/test

 

Original URL: /:item/:item2/:item3.html

Redirected To: /{item}/{item2}/{item3}

*would work for URLs with the pattern of www.test.com/test/test/test.html > www.test.com/test/test/test