ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Pages uri in multi country setup

January 03, 2012 11:28pm

Subscribe [4]
  • #1 / Jan 03, 2012 11:28pm

    Jacek Sompel

    15 posts

    Hi,

    Could someone tell if it’s possible to use the same page uri in a multi-country EE setup.

    I have clients website running with multiple countries in following setup:

    1. Main site
      index.php
      admin.php

    2. USA site
      /us/index.php

    3. France site
      /fr/index.php

    etc

    Eg. I have Privacy Policy page with main site link as /privacy. How can you have /us/privacy to be recognized as a USA page? If I enter /us/privacy into Pages tab Page Uri field it expects the page to be accessed via http://www.domain.com/us/us/privacy not http://www.domain.com/us/privacy. Obviously if I try to use /privacy on the USA page EE will not let you use it as it’s already taken by the main site.

    Is there any way to do it?

    Thanks,
    Jacek

  • #2 / Jan 04, 2012 4:09am

    Andrew Fairlie

    126 posts

    Hi there,

    One way to do multi-lingual sites is to use Multi-Site Manager and have each region operate as their own ExpressionEngine install. Another way would be to add the Privacy page once but have duplicate fields for each language. For example the body of the page may be called:-

    static_en_body
    static_fr_body

    You could then possibly use URI segments to detect the language and load the fields based on that. For example if the URL structure was http://www.domain.com/privacy/en (not quite what you want I know, but the concept could be built upon) it would load the privacy page. Then on the page you could feasibly load fields like so:-

    {static_{segment_2}_body}

    You would probably want some logic in there so if segment_2 is empty is defaults to “en”. Hopefully this helps you in the right direction. If you need more help just let us know.

  • #3 / Jan 04, 2012 8:19pm

    Jacek Sompel

    15 posts

    Hi Andrew,

    Yes I am aware of this method but was hoping there would be an alternative as I am trying to maintain the link simplicity.
    This method isn’t quite suitable when you have 10+ languages as it simple creates too many fields and if you wish for each country to have their own user then this causes a mess.

    Hope, there still is another way.

    Jacek

  • #4 / Jan 05, 2012 12:38am

    Dan Decker

    7338 posts

    Hi Jacek,

    I’m afraid Pages will only allow for one URI. When you set up the URI as “us/privacy” for example, how are you generating the link to that page in your navigation? Have you set any global variables in each county’s index.php? Are you using .htaccess in any way? I’ve had some experience getting ExpressionEngine to serve multiple countries in the manner you are using, I just need a little more context about how you are going about it.

    Thanks!

  • #5 / Jan 05, 2012 1:02am

    Jacek Sompel

    15 posts

    Hi Dan,

    I’ve followed one of the guides on how to set up multilingual sites with EE.
    As I mentioned I basically have each country index.php inside its own folder name based on the country code eg. us, au, fr, ca etc

    Each index.php would have something like this:

    $assign_to_config['template_group'] = '';
      $assign_to_config['template'] = '';
      $assign_to_config['site_index'] = '';
      $assign_to_config['site_404'] = '';
      $assign_to_config['global_vars'] = array(
        "country_name" => "United States",
        "country_code" => "us",
        "language_name" => "english",
        "language" => "en",
        "language_name_alt" => "",
        "language_alt" => ""
      );

    It contains some extra variables to help me set second country language and code.

    The .htaccess file contains this:

    <IfModule mod_rewrite.c>
      RewriteEngine On
    
      # Catch any Google campaigns directed to the home page
      RewriteCond %{REQUEST_URI} ^/us/$
      RewriteCond %{QUERY_STRING} (gclid=.*)
      RewriteRule ^(.*)$ /us/index.php/? [L,PT]
    
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-l
      RewriteCond $1 !^(images|_system|themes|index\.php|admin\.php) [NC]
      RewriteRule ^(.*)$ /us/index.php/$1 [L]
    </IfModule>

    My problem is that to be able to get pages uri to work I obviously would need to give it a unique name. As I mentioned, I’ve tried /us/privacy but the end result would expect the URL to be http://www.domain.com/us/us/privacy.

    You now actually got me thinking about the .htaccess file whether to detect if the page requested is not the home page and then append the us/ to the URL.

    Anyway, any advice would be great.

    Thanks,
    Jacek

  • #6 / Jan 05, 2012 7:23pm

    ahmad saad

    364 posts

    if you post how you generate the link on your template.

  • #7 / Jan 05, 2012 7:38pm

    Dan Decker

    7338 posts

    Hi Jacek,

    You are right, that is going to get in the way here…

    You could make a privacy template group, then have the index template in that group pull the correct entry based on your “country_code” global variable. Does that make sense? It wouldn’t be a Page per se, but you would get the same URL structure and end result.

  • #8 / Jan 10, 2012 1:48am

    Jacek Sompel

    15 posts

    Hi Dan,

    I got it working.

    I had to use /us/privacy or /ca/privacy in Pages Uri.

    Then adjusted the .htaccess in each country folder to the following:

    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-l
      RewriteCond $1 !^(images|system|themes|index\.php|admin\.php) [NC]
      RewriteRule ^(.*)$ /us/index.php/us/$1 [L]
    </IfModule>

    Works as expected.

    Jacek

  • #9 / Jan 12, 2012 8:45pm

    Sean C. Smith

    3818 posts

    Jacek,

    Glad to see that Dan got you all sorted out. Feel free to post again when you have more questions.

    Sean

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases