Problems with friendly URL in codeigniter

0

I have the following problem.

I'm working with a system in CodeIgniter and need to remove the index.php from the url.

My .htaccess is as below:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|assets|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

The index.php itself has been solved. The problem is that the system has a language plugin and the configuration of the link is as below:

www.site.com.br/pt/controller

The issue is that this htacces is overwriting pt and I can not remove this pt. And in case, they will have other languages like en, es and etc.

How do you resolve this?

    
asked by anonymous 23.11.2016 / 18:44

1 answer

1

Change the line

RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

for

RewriteRule ^([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_\s]+)[\/]?(.+)?$ index.php?1=$1&2=$2&3=$3 [NC,L]
RewriteRule ^([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)?$ index.php?1=$1&2=$2 [NC,L]
RewriteRule ^([a-zA-Z0-9\-\_]{1,})?$ index.php?1=$1 [NC,L]

then to access the URL pt you can use:

$_GET['1']

and so on.

    
23.11.2016 / 18:53