PerchRunway URL rewrite for multilingual site

  • What do you suggest for a multilingual runway site ?


    I was hoping to have urls like mydomain.com/en and mydomain.com/fr both map to a single page "home" with location path / then for each editable region, append the language key to the region name so that on the page being edited in perch, there are multiple regions for each content, one for each language.


    I've tried setting a url pattern [en|fr:lang] but this doesn't seem to work with the top most parent page /. If i create a page /test then add the same url pattern to the test page /test/fr comes through correctly, it gets mapped to /test and perch_get('lang') shows 'fr'. But this doesn't work with '/' as a page path for some reason.


    I've also tried modifying the htaccess file as follows:


    Code
    1. # Perch Runway
    2. RewriteEngine On
    3. RewriteCond %{REQUEST_URI} ^/en|fr
    4. RewriteCond %{REQUEST_FILENAME} !-f
    5. RewriteRule ^(en|fr) /perch/core/runway/start.php?lang=$1 [L]
    6. RewriteCond %{REQUEST_URI} !^/perch
    7. RewriteCond %{REQUEST_FILENAME} !-f
    8. RewriteRule .* /perch/core/runway/start.php [L]


    to try to catch the language and pass it to the start script as a query string parameter. The QS param works but the REQEUST_URI is still /fr or /en and I would like it to redirect to /


    Essentially what i would like to do is to transform the /en or /fr of the url to a query string param and have perch ignore it in the uri


    Is that possible ?


    Thanks.

  • drewm

    Approved the thread.
  • hus_hmd


    Sorry, so let me elaborate.


    so here what I want to accomplish:


    URL: https://mydomain.com/en to have Runway render the page with location path / and have ?lang=en.


    Right now with the above rewrite rules i get Runway trying to render /en with ?lang=en which the /en page doesn't exist in the page hierarchy. so I get the Perch rendered 404 page.


    The point of all this is to have only 1 set of pages but duplicated content regions appended with the EN or FR to distinguish between content language. The editor would prefer to edit only 1 page but multiple regions on that 1 page rather than have to duplicate the entire site structure.



    Does that make more sense ? Thanks for your help.

  • I get what you're trying to accomplish. It wasn't clear what exactly isn't working from the original post so I wanted to double check before suggesting anything.


    So you have added the URL pattern [en|fr:lang] (no slash at the start) to the home page /, but visiting both /en and /fr gets you a 404.


    Routes work fine on / in general. Have you tested other routes on the same page?