0

Lets say I have a site example.com with the following urls:

example.com
example.com/page1
example.com/about

This is an American site, but I also want an Australian version.

The urls for the Australian site will be:

example.com/au
example.com/au/page1
example.com/au/about

The homepage and page1 are identical on both sites so the same content is served. However there is an Australian specific version of about so different content is served.

How can I map all of the /au pages to the ones without /au and somehow pass the fact that it is an AU page so I can determine what content to serve?


Update:

To clarify I want every single page that exists to be accessible via it's normal path alias, or the normal path alias prefixed with "au/".

I have managed to achieve this by editing bootstrap.inc in the following way:

A. Alter request_path(). After the line:

$path = substr(urldecode($request_path), $base_path_len + 1);

I added:

if(substr($path, 0, 3) == 'au/') {
  $path = substr($path, 3);
  $_SESSION['au'] = TRUE;
} else {
  $_SESSION['au'] = FALSE;
}

B. Alter drupal_settings_initialize(). After the $base_path has been set add:

if(isset($_SESSION['au']) && $_SESSION['au']) {
  $base_path = '/au/';    
}

This means both /page and /au/page are treated in exactly the same way and I can use $_SESSION['au'] in a node preprocessor hook to determine which content to serve.

Now my question is how can I achieve this behaviour without hacking the core?

7
  • 1
    drupal.org/project/domain - this allow configure site as you want...
    – Nikit
    Jun 25, 2014 at 4:15
  • That sounds promising. I can see it can map the same drupal instance to multiple subdomains but can't see any mention of using a country code url prefix such as /au/page. Do you know if this is possible with this module?
    – Felix Eve
    Jun 25, 2014 at 4:19
  • 2
    yes, you can, read please: trellon.com/content/blog/sharing-content-domain-access - so you can create "about" for all affilliates, and "au/about" to only australian...
    – Nikit
    Jun 25, 2014 at 4:29
  • Yes! That is exactly what I want to achieve. Thanks for the link. Hopefully that should solve all my problems :)
    – Felix Eve
    Jun 25, 2014 at 4:36
  • Hmm, after having read most of the documentation and gone though the issue queue I'm struggling to find anything on using country code url prefixes. That blog post does mention it but does not go into enough depth to be useful and they are also using an outdated version of the module. Will continue looking...
    – Felix Eve
    Jun 25, 2014 at 6:16

1 Answer 1

1

Use i18n. It does this for you.

You have the possibility to choose how the content is served (from the module configuration page), between a subdomain for ex. "au.mysite.com/post-name" and prefixes like "mysite.com/au/post-name".

You will have a language field for your content-type, and you can easily set different content for different languages.

1
  • Just got this working. Not only does it map /au/contact to /contact but also updates all links with the country code prefix. The key to getting this working was to check the Detection and selection settings and enable URL. Thanks for your help :)
    – Felix Eve
    Jun 26, 2014 at 3:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.