Playing parameter in url

1

I have a Project in Codeigniter that will be in two languages, however I need to allow this language change only in the project URL;

In other words, when accessing the domain.com it should maintain as a base url / pt on all pages and consecutively the same thing with / en;

Has anyone ever had to do this? Here is the code for my .htaccess, config and constants:

Htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteCond %{HTTP_HOST} ^www\.(.*)
    #RewriteRule (.*) http://%1/$1  [R=301,L]

    RewriteBase /cliente/em_desenvolvimento/back/mauricio/

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

Config:

$config['base_url'] = 'http://192.168.110.4/cliente/em_desenvolvimento/back/mauricio/';

Constants:

define('PATH_FRONT_END', $_SERVER['DOCUMENT_ROOT'] . '/cliente/em_desenvolvimento/back/mauricio/');
         define('PATH_FRONT_END_UPLOAD', $_SERVER['DOCUMENT_ROOT'] . 'cliente/em_desenvolvimento/back/mauricio/web_files/uploads/');

I think something can be done on routes, but I have no idea how this can be done.

    
asked by anonymous 18.04.2017 / 13:34

1 answer

1

A constant was created to play the language in the url:

                define('base_path', 'cliente/em_desenvolvimento/back/mauricio/');                
                $uri_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
                $uri_path = str_replace(base_path, '', $uri_path);
                $uri_segments = explode('/', $uri_path);

                switch ($uri_segments[1]) {
                    case 'pt':
                        define('idioma_site', 'pt');
                    break;
                    case 'es':
                        define('idioma_site', 'es');
                    break;
                    case 'en':
                        define('idioma_site', 'en');
                    break;
                    case 'cms':
                    break;
                    default:
                        header('location: http://192.168.110.4/cliente/em_desenvolvimento/back/mauricio/pt');
                        //header('location: http://192.168.110.4/cliente/em_desenvolvimento/back/bernardo/pt');
                        exit();
                    break;
                }
    
24.04.2017 / 16:42