Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i've a multilanguage site. I've set up the .htaccess and urlmanager rules, and they correctly works. One last thing remain

I want that direct visit to www.mysite.com auto append the language in this way:

 www.mysite.com -> www.mysite.com/en/ or obviously to www.mysite.com/fr/ etc etc

Now with my rules, after the first access to the home, all the links to the home thanks to ovverriden createUrl correctly became www.mysite.com/en/ but not the first access in case a user directly wrote in the browser www.mysite.com

How can make also the first access url to became www.mysite.com/en/?

I can assign a default language in case the aren't no cookie or no session or no GET or POST params.

Help me!!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
187 views
Welcome To Ask or Share your Answers For Others

1 Answer

If your default Controller is site/index, then you can do like this.

 public function actionIndex() {
        if(!isset($_GET['lang'])){
            $this->redirect(array('site/index','lang'=>'de')+$_GET); // 'de' is considered as default language
        }
        ---
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...