We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question

Redirect a page in Perch Runway?

Is there a way in Perch (Runway) to redirect my /legal page to /legal/terms-and-conditions

This is my page structure:

  • /legal
  • /legal/cookie-policy
  • /legal/terms-and-conditions
  • /legal/privacy-policy

/legal is just a parent container page, it's a blank page. I'd like to setup a redirect incase anyone (or search bots) find their way there.

I vaguely remember watching a video when Perch Runway was first released, that did just this (perhaps). But I can't find it.

Stephen Meehan

Stephen Meehan 4 points

  • 1 year ago

Hi Stephen,

have a look here: https://docs.grabaperch.com/functions/utilities/perchsystem/

PerchSystem::redirect('/legal/terms-and-conditions');

put this on your legal-Page and it will be redirected to /legal/terms-and-conditions

Hi Rene,

Thanks for the tip. Unfortunately it doesn't work....

I'm using the same page template for lots of pages, so I needed a way to only run the PerchSystem::redirect on this page /legal

I came up with this demo:

<?php 

$page = PerchSystem::get_page();

if ($page == '/legal') { 
     echo "This is the /legal page";
 }

?>

The above works, "This is the /legal page" is shown only the /legal page

<?php 

$page = PerchSystem::get_page();

if ($page == '/legal') { 
    PerchSystem::redirect('/legal/terms-and-conditions');
 }

?>

I was hoping the above code would work in the same way, run the PerchSystem::redirect if the page is /legal

But the page doesn't load, it's just white/blank and there's nothing in the source...

Hi,

Thanks for pointing me in the direction of that great post.

I couldn't get it to work. I'll try and figure it out when I have some time.

However, I was able to edit the concept to fix the problem I had, it's not flexible - but it works.

<?php
header('Location: http://my-site.com/legal/terms-and-conditions');
?>

Create a master page with just this php, and apply it to the parent page to redirect all requests to that page to /legal/terms-and-conditions