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

Redirect segment to external website

Development and Programming

killeenchamber's avatar
killeenchamber
3 posts
9 years ago
killeenchamber's avatar killeenchamber

I need to redirect this segment to an external website.

{if:elseif segment_2 == "today"}
 
 <div class="banner {url_title}">
  <div class="row">
   <div class="large-12 large-centered columns">
    <h1 class="text-center">Join Today</h1>
   </div>
  </div>
 </div>
 
 <div class="page tiers">
  
  <div class="row page-content">
   <div class="large-9 large-centered columns">
       
Derek Jones's avatar
Derek Jones
7,561 posts
9 years ago
Derek Jones's avatar Derek Jones

Is your code sample complete?

For redirects based on the URL, you should probably use .htaccess, so those requests don’t consume server resources. If you can elaborate on your example, someone here can help you with the code necessary.

       
killeenchamber's avatar
killeenchamber
3 posts
9 years ago
killeenchamber's avatar killeenchamber

Wonderful! Here’s more of the code:

{layout="site/.layout"}
 
 {if segment_2 == ""}
 
 {layout:set name="title"}Pricing{/layout:set}
 <div class="banner">
  <div class="row">
   <div class="large-12 large-centered columns">
    <h1 class="text-center">Pricing</h1>
   </div>
  </div>
 </div>
 
 <div class="page tiers">
  
  <div class="row page-content">
   <div class="large-9 large-centered columns">
    
    {exp:low_reorder:entries set="membership_options" disable="member_data|category_fields"}
    
    <div class="{if cf_memberships_color == 'Red'}engage {if:elseif cf_memberships_color == 'Green'}build {if:elseif cf_memberships_color == 'Blue'}lead {if:elseif cf_memberships_color == 'Yellow'}invest {/if}tier">
     <div class="tier-top-section">{cf_memberships_value_statement}</div>
     <div class="tier-body">
      <div class="row">
       <div class="medium-9 columns">
        <h3 class="tier-title">{title}<span class="price"> {cf_memberships_price}</span></h3>
        {cf_memberships_summary}
       </div>
       <div class="medium-3 columns">
        <a href="http://{title_permalink=join/}" class="expand {if cf_memberships_color == Red}alert {if:elseif cf_memberships_color == Green}success {if:elseif cf_memberships_color == Blue}{if:elseif cf_memberships_color == Yellow}warning {/if} radius button">Learn More</a>
       </div>
      </div>
     </div>
    </div>
    
    {/exp:low_reorder:entries}
    
   </div>
  </div>
  
 </div>
 
 {if:elseif segment_2 == "today"}
 
 <div class="banner {url_title}">
  <div class="row">
   <div class="large-12 large-centered columns">
    <h1 class="text-center">Join Today</h1>
   </div>
  </div>
 </div>
 
 <div class="page tiers">
  
  <div class="row page-content">
   <div class="large-9 large-centered columns">
    
    [removed][removed]
<iframe frameBorder="0"  height:auto; border:0; overflow:hidden;' id='paywhirl_frame' scrolling='no' src="https://www.paywhirl.com/widget?api_key=PW2D777CF025864218DBB4286BA48A4D77&widget=3236"></iframe>

    
   </div>
  </div>
  
 </div>
 
 {if:elseif segment_3 == "today"}
 
 <div class="banner {url_title}">
  <div class="row">
   <div class="large-12 large-centered columns">
    <h1 class="text-center">Becoming an Investor in the Chamber</h1>
   </div>

We are no longer using the paywhirl service and instead are linking to this: https://killeentxcoc.wliinc32.com/join-us/application.aspx

So we need the “today” to redirect to this external page.

Thanks so much!

       
Derek Jones's avatar
Derek Jones
7,561 posts
9 years ago
Derek Jones's avatar Derek Jones

So http://example.com/something/today/* needs to go to https://killeentxcoc.wliinc32.com/join-us/application.aspx is that correct? If you give me the full URL, or at least what is supposed to be in segment 1 as well, I can give you the appropriate redirect. You won’t need to do it in your templates, and can remove that conditional logic after applying the redirect at the server level.

p.s. I edited your post to use [c;ode;][/code] blocks, feel free to use that in the future when sharing code samples so it displays properly.

       
killeenchamber's avatar
killeenchamber
3 posts
9 years ago
killeenchamber's avatar killeenchamber

Correct. We need this:

http://killeenchamber.com/join/today

to redirect to this:

https://killeentxcoc.wliinc32.com/join-us/application.aspx

Thanks!

       
Derek Jones's avatar
Derek Jones
7,561 posts
9 years ago
Derek Jones's avatar Derek Jones

So in your .htaccess file in the root public HTML folder, you can just add:

Redirect 301 /join/today https://killeentxcoc.wliinc32.com/join-us/application.aspx

Then ExpressionEngine won’t be handling that routing or spinning up server resources for requests made to /join/today. Make sense?

       
MIssy's avatar
MIssy
3 posts
9 years ago
MIssy's avatar MIssy

Thanks so much! This is now working for me. I appreciate your help!

       
MIssy's avatar
MIssy
3 posts
9 years ago
MIssy's avatar MIssy

How do I set so this so it opens in a new window?

       
MIssy's avatar
MIssy
3 posts
9 years ago
MIssy's avatar MIssy

nevermind on that. It’s fine the way it is.

       

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.