How do I get the right entry data based on locale and slug? My site has 2 locales: en_us and nl_nl. I also have a Structure section called Pages, which targets both locales. For each locale, the section has an Entry URL Format:


en_us: en/{slug}
nl_nl: nl/{slug}


The Entry Template setting for the section is pages/_entry, and there is a template there.

Now, for an entry with the slug home for both locales, the URI nl/home gives me the correct page, but en/home gives me a 404.

Is my setup wrong? Do I need to explicitly create nl and en template folders?
Probably the CRAFT_LOCALE isn't set correctly. There is an in-depth knowledge article here.

To solve this, you could add a conditional to the /public/index.php:

// Path to your craft/ folder
$craftPath = '../craft';

//Locale
if ( preg_match("/\/nl\//i", $_SERVER['REQUEST_URI']) ) { //Check if /nl/ is in the uri
    define('CRAFT_LOCALE', 'nl_nl');
}
else {
    define('CRAFT_LOCALE', 'en_us');
}