Problems with friendly url in codeigniter

Asked

Viewed 290 times

0

I have the following problem.

I am working with a Codeigniter system and need to remove 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 already been solved. The problem is that the system has a language plugin and the link configuration is as below:

www.site.com.br/pt/controller

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

How do you fix this?

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.

  • 1

    vlw guy.... worked here... Rigadão

Browser other questions tagged

You are not signed in. Login or sign up in order to post.