duanbohan2015 2015-07-24 06:16
浏览 60

使用codeigniter的多语言站点

I want to setup a multi language site for my web app. But I'm rather confuse on where to start. I'm using Codeigniter and hosted my domain in a cpanel server.

What I want to have is multi language with subdomains such as:

en.abc.com for english
id.abc.com for indonesia

So far, I have set up the advanced DNZ Zone editor and point the subdomains to the server IP address. But, I don't know what to do next. I have read on some tutorial to set the .htaccess, etc. But it doesn't work.

This is my .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^(/index\.php|/assets|/robots\.txt|/favicon\.ico)
RewriteRule ^(.*)\.html$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^(/index\.php|/assets|/robots\.txt|/favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{HTTP_HOST} ^en\.lokadok\.co.id$
RewriteCond %{REQUEST_URI} !^/en/
RewriteRule (.*) /en/$1

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

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

I got the 404 not found error everytime I access the subdomains which redirected to address like:

http://www.en.abc.com/en/index.php/en/ 

My question is, from where should I start implement it?

Thanks.

  • 写回答

1条回答 默认 最新

  • doumi7854 2015-07-24 06:40
    关注

    For me this looks like a structure problem rather than a CI problem but i'll give you some thought about it

    1. You should think about whether you need different models and controllers per language or not.

    2. If you need different models etc. simply create 2 different CI installations. For example - since you are using Apache, i give you a concrete example: Make in your document root Folder for each language a folder and point any subdomain via vhost to the appropriate directory. As alternative you can use CI as a mulitple application environment take a look at this link

    3. if you wish to choose the same models, controllers and views, you really have to think about your routing. Do you wish the same url names for all languages or do you like language dependent urls (for this purpose you should think about a pre controller hook with a DB System behind of that to choose where the link should route to the desired controller)

    4. in your url http://www.en.abc.com/en/index.php/en/ there are too much "ens". In fact if you have a language prefix as subdomain you don't need "en" at all as a suffix. En.abc.com is the way to go.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。