For testing purpose, I copied all the code and DB records from our live server to a local server.
Our live server is redirecting www.our-site.eu
to www.our-site.eu/en
and then display the homepage with specific language.
The same code, same DB hosted locally, is totally failing. localhost
is well redirected to localhost/en
. But then an error 404 happend : The requested URL /en/ was not found on this server.
system\core\CodeIgniter.php
$EXT->_call_hook('pre_controller');
application\config\hooks.php
$hook['pre_controller'][] = array(
...
);
$hook['pre_controller'][] = array(
'class' => 'MY_Lang',
'function' => 'define_language',
'filename' => 'MY_Lang.php',
'filepath' => 'core',
'params' => array()
);
$hook['pre_controller'][] = array(
...
);
application\core\MY_LANG.php
...
header('Location: '.$config['base_url'].$index_page.$URI->uri_string); //http://localhost/en
exit;
...
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(themes)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|assets|static|img|css|js|map|favicon\.ico)
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]
RewriteRule ^sitemap\.xml$ ./index.php?/$1 [L,QSA]
RewriteRule ^robots\.txt$ ./index.php?/$1 [L,QSA]
</IfModule>
<IfModule mod_deflate.c>
<filesMatch "\.(js|css|png)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>
AddOutputFilterByType DEFLATE text/ico text/html text/plain text/xml text/css application/javascript application/x-javascript application/x-httpd-php application/rss+xml application/atom_xml text/javascript
My main config.php have to following line $config['base_url'] = 'http://localhost/';
I am pretty new to CodeIgniter, so I do not really know why it is working on the live server and not locally.
The url_rewriting
is active on both servers.