Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Mod_rewrite issues with i18n internationalization
#1

[eluser]du7ch[/eluser]
I'm building a bilangual (english - french) site using the i18n internationalization supplied in CodeIgniter's GitHub page. This allows the language (en/fr) to be included in the URI before the controller.

Everything works fine when I leave the index.php in the URI. www.mydomain.com/index.php/welcome gets routed properly to www.mydomain.com/index.php/en/welcome

However, when I try to hide index.php using the htaccess file it doesn't seem to work. I get a 404 error if I input either: www.mydomain.com , www.mydomain.com/en , www.mydomain.com/en/welcome . The url appears correctly (www.mydomain.com/en/welcome) but CodeIgniter doesn't seems to handle the parameters well.

Here are my file configurations (the config is relative to MAMP running on my local machine and CodeIgniter is running in a subfolder named ci).

config.php
Code:
$config['base_url'] = 'http://localhost:8888/ci/';
$config['index_page'] = '';

routes.php

Code:
$route['default_controller'] = "welcome";
$route['404_override'] = '';

$route['^fr/(.+)$'] = "$1";
$route['^en/(.+)$'] = "$1";

$route['^fr$'] = $route['default_controller'];
$route['^en$'] = $route['default_controller'];

MY_Lang.php This file is included with i18n internationalization module

Code:
var $languages = array(
'en' => 'english',
'fr' => 'french'
);

// special URIs (not localized)
var $special = array (
""
);

// where to redirect if no language in URI
var $default_uri = 'en/welcome';

.htaccess
Code:
RewriteEngine On
RewriteBase /ci/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

I don't believe I'm missing anything in terms of configuration.

If anyone could help out it would be greatly appreciated.
Thanks.
#2

[eluser]NeoArc[/eluser]
Umm, there are some issues with MAMP, try this..

http://ellislab.com/forums/viewthread/178186/#844583
#3

[eluser]du7ch[/eluser]
Ok, so I thought that the suggestions in the other thread were going to help as the index.php was causing my issue. My .htaccess file now looks like this

Code:
Options -Indexes
OPtions +FollowSymLinks
OPtions -MultiViews

DirectoryIndex index.php

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /ci/

   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d

   RewriteRule ^(.*)$ ci/index.php/$1 [NC,L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
   ErrorDocument 404 index.php
</IfModule>

However, I'm still getting a 404 error when entering something like localhost:8888/ci/en/welcome

I took a look at the Apache logs and this is what I have

Code:
[Mon Aug 27 10:47:59 2012] [error] [client ::1] File does not exist: /Applications/MAMP/htdocs/ci/en, referer: http://localhost:8888/ci/

/en seems to be being handled like a folder or a controller and not like the language. I never had this problem when I wasn't trying to hide index.php
#4

[eluser]NeoArc[/eluser]
Perhaps the .htaccess files are disabled by default in the apache .conf file

<VirtualHost *:80>
#.....
#.....
<Directory /sites/momentum>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
#5

[eluser]du7ch[/eluser]
Everything seems to be ok
Code:
<Directory "/Applications/MAMP/htdocs">

    Options All

    AllowOverride All

    Order allow,deny
    Allow from all

</Directory>

I think the problem is within the library itself, because I have another site in a different sub-folder in my htdocs folder and the rewrite rules are being applied correctly there.

Has anyone else experienced this with the Internationalization library?
#6

[eluser]du7ch[/eluser]
I figured it out. I'm really kicking myself in the butt for this.

The rewrite rules were all in the .htaccess file that was within the application folder. I simply copied the file into the root (in my case the ci folder one level above the application folder) and everything is now working perfectly.




Theme © iAndrew 2016 - Forum software by © MyBB