Thread tagged as: Question, Runway

Runway: Set default route for all pages

I'm building a multi-lingual Runway site. The language is set like this:


$validLangs = array('en','zh','fr','es','pt');
$currentURI = explode('/', $_SERVER['REQUEST_URI']);
$lang = $currentURI[1];

// redirect to correct language if necessary
if (!in_array($lang, $validLangs)) {
  $browserLangs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
  foreach ($browserLangs as $thisLang) {
    $thisLangPrefix = substr($thisLang,0,2);
    if (in_array($thisLangPrefix, $validLangs)) {
      $currentURI[1] = $thisLangPrefix.'/'.$currentURI[1];
    $currentURI[1] = 'en/'.$currentURI[1];
  $currentURI = join('/', $currentURI);
  header('Location: https://'.$_SERVER['SERVER_NAME'].$currentURI);

// replace Perch title with current language title if it exists
if (!empty(perch_page_attribute($lang.'_page_title',['template'=>'title-nav-text.html'],true))) {
    'pageTitle' => perch_page_attribute($lang.'_page_title',['template'=>'title-nav-text.html'],true)

// set Perch lang variable
PerchSystem::set_var('lang', $lang);

I'm also giving editors the ability to create their own pages using a master template which looks like:


        <div class="section">
            perch_content_create('Content', array(
              'template' => 'shared/text_block.html',
              'multiple' => false,
              'edit-mode' => 'singlepage',


For this to work, every page needs a route that looks like [lang]/page-path. It would be great if I could somehow set this default route for all pages so that the editor doesn't need to create this route every time they create a new page. Can this be accomplished through .htaccess or some Runway setting somehow?

Shane Lenzen

Shane Lenzen 18 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

This isn't something we have plumbing in place for currently, but it is something we've been thinking about adding.

Got it. Thanks for the quick reply, Drew.