1

I have a localized site set up where the language switcher and translations are working fine. However when I link to internal pages it goes to a 404.

general.php has this:

 //local only
 'etf-craft.dev' => array(
    'devMode' => true,
    'siteUrl' => array(
       'en' => 'http://etf-craft.dev/en/',
       'fr' => 'http://etf-craft.dev/fr/'
   ),
   'environmentVariables' => array(
        'environment' => 'local',
        'basePath' => 'D:\sites\etf-craft\public_html',
        'baseUrl'  => 'http://etf-craft.dev',
    )
),

site structure is like this:

  • craft
  • public
  • public/en/
  • public/fr/

index.php in /fr/ and /en/ directories contains the following where french says /fr/ instead of /en/:

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

// Tell Craft to serve the English content
define('CRAFT_LOCALE', 'en');

One link I've created that 404s on me is:

  <li>
    <a href="/{{ craft.locale }}/news" class="news">{{ "News" | t}}
      <i class="arrow right"></i>
    </a>
  </li>

What I expect is that it takes me to http://etf-craft.dev/en/news and the news page shows up. However I end up going to a 404.

However if I manually remove the /en/ from the address bar the news template shows up correctly.

What am I doing wrong?

  • Does each folder (en|fr) have an .htaccess file too? – Natetronn Nov 13 '17 at 22:20
  • It did not, but I copied one in now and no change. – CreateSean Nov 13 '17 at 22:22
  • Did you update the craftPath var in both index.php $craftPath = '../../craft';? – Natetronn Nov 13 '17 at 22:27
  • @Natetronn Yes that was previously set correctly - updating the post now with that information – CreateSean Nov 13 '17 at 22:39
  • Not sure if it matters either way but, looks like you're missing a comma in the siteUrl array 'fr' => 'http://etf-craft.dev/fr/', – Natetronn Nov 13 '17 at 22:52
3

First off, make sure you have .htaccess files in both the en and fr folders and this per the localization guide.

Secondly, you're missing a comma in the siteUrl array:

'siteUrl' => array(
    'en' => 'http://etf-craft.dev/en/',
    'fr' => 'http://etf-craft.dev/fr/' <--------add comma here-----
),
| improve this answer | |
  • That comma isn't necessary there... – andrew.welch Nov 19 '17 at 9:54
  • Aside from avoiding future syntax errors, should he add other languages in the future, you're right. Then again, ¯_(ツ)_/¯ – Natetronn Nov 20 '17 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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