We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

how to redirect? problems using a variable inside of {redirect}

How Do I?

liberty79's avatar
liberty79
135 posts
6 years ago
liberty79's avatar liberty79

I’ve consolidated a few templates into one master template and would like to redirect all those templates to the new master template.

For example:

www.website.com/vehicles/trucks/2019model.html www.website.com/vehicles/vans/whitevan.html www.webiste.com/vehicles/motorcycle/harley.html

I want to be able to go to any of those urls and redirect to

www.website.com/vehicles/model/2019model.html www.website.com/vehicles/model/whitevan.html www.webiste.com/vehicles/model/harley.html

I’m testing this by throwing a {redirect} tag in the previous templates, but I can’t get that last URL segment to pass with the redirect.

for example, this doesn’t work:

{redirect="vehicles/trucks/{entry_id}” status_code=”301”}

nor does this:

{redirect="vehicles/trucks/{url_title}” status_code=”301”}

I understand that wouldn’t work, but I don’t know how to do this correctly. Any thoughts?

       
Robin Sowell's avatar
Robin Sowell
13,158 posts
6 years ago
Robin Sowell's avatar Robin Sowell

A segment variable should work, so

{redirect="vehicles/trucks/{segment_3}" status_code="301"}

Would that do the trick?

       
liberty79's avatar
liberty79
135 posts
6 years ago
liberty79's avatar liberty79

perfect! that does work. Thanks so much

       
Robin Sowell's avatar
Robin Sowell
13,158 posts
6 years ago
Robin Sowell's avatar Robin Sowell

Glad it was an easy fix!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.