M
M
Maxim2014-02-28 16:42:40
Yii
Maxim, 2014-02-28 16:42:40

How to save page url when switching site to Yii?

The situation is this: the site is translated into Yii, and you need to save the paths to some pages, due to the fact that they are well indexed by the search engine.
Task:
There are pages with a URL like:
site.ru/seo_word1
site.ru/seo_word1/filter1/param1
, etc.
At the moment, the paths on the version with the yii engine are:
site.ru/site/index/section/1
site.ru/ site/index/section/1/filter1/param1
What are the ways to solve the problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kLkA, 2014-03-02
@kLkA

In Yii, you can write any kind of urls you want using routing. If I understand you correctly, then you have 3 get parameters seo_word, filter, param
in the config, you can write a rule

'components'=>array(
        …
        'urlManager'=>array(
            'urlFormat'=>'path',
            'rules'=>array(
                  '<seoword:\w+>/<filter:\w+>/<param:\w+>'=>'site/index'
            ),
        ),
    ),

in this rule, the urls /SEO_word12313/filter2/param17 will be caught by actionIndex
now we collect data from the get request via Yii::app()->request->getParam("seoword")
public function actionIndex() {
                Yii::app()->request->getParam("seoword")
                Yii::app()->request->getParam("filter")
                Yii::app()->request->getParam("param")
    $this->render('index');
  }

or immediately
public function actionIndex($seoword,$filter,$param) {
    $this->render('index');
}

S
Sergey, 2014-02-28
Protko @Fesor

set routes not as < controller >/< action> but normally.

A
asd111, 2014-02-28
@asd111

In urlManager settings write
showScriptName => false

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question