A
A
AlexRas2017-09-13 16:13:09
Yii
AlexRas, 2017-09-13 16:13:09

How to correctly write a regular expression in the urlmanager yii2 rules settings?

Hello, there is such a rule: It is
'//<city>.domen.ru/search' => 'search/index',
necessary that city is not substituted if it is equal to moscow
I did this:

'//<city:^(?!moscow).*?>.domen.ru/search' => 'search/index',

Works but stops working Yii::$app->request->get('city').

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-09-13
@AlexRas

config:

'//<city>.domen.ru/search' => 'search/index',
'//domen.ru/search' => 'search/index',

controller
public function actionIndex($city='без поддомена'){
 return $city;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question