Guillaume Lavoie
Guillaume Lavoie

Reputation: 567

Masking CodeIgniter subfolder install with internationalized url

I have the a html/shtml website installed at the root of my public_html folder and a CodeIgniter install in the "ci_code" subfolder and two .htaccess files: one in the root folder and one the "ci_code" folder.

To access the CodeIgniter, website, I use the following url:
example.com/ci/{params}

I would like to mask to CodeIgniter folder name with internationalized url like these
example.com/ci_spanish/{params}
example.com/ci_english/{params}

How can I do this?


Root (/) .htaccess files

RewriteBase /

AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
Options +Indexes +Includes

CodeIgniter .htaccess file

RewriteBase /ci/

RewriteCond %{REQUEST_URI} .*/application/views/.*
RewriteRule ^(.*)$ $0 [L]
RewriteCond %{REQUEST_URI} .*/application/modules/.*
RewriteRule ^(.*)$ $0 [L]
RewriteCond %{REQUEST_URI} /system/.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_URI} /application/.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Upvotes: 0

Views: 237

Answers (1)

stormdrain
stormdrain

Reputation: 7895

RewriteRule ^ci(.*)/(.*) /ci/$2

will turn a URL like

http://example.com/ci_engish/test

into

http://example.com/ci/test

However, then there is no way that I can see to tell CI which language you are going after. You could also do something like

RewriteRule ^ci_(.*)/(.*) /ci/$1/$2

which will turn a URL like

http://example.com/ci_engish/test

into

http://example.com/ci/english/test

from which you could use routes or some other mechanism to deal with the language.

http://htaccess.madewithlove.be/ and http://martinmelin.se/rewrite-rule-tester/ are nice little utilities to test .htaccess stuff

Upvotes: 0

Related Questions