Answer the question
In order to leave comments, you need to log in
Why is there no GET parameter in (yii2-advanced)?
I tried in every possible way to extract the get parameters from the URL. They simply don't exist ( url : "site.com/page?a=b" ).
The most common default controller created via gii with one method (index).
class TestController extends \yii\web\Controller
{
public function actionIndex()
{
return $this->render('index');
}
}
Yii::$app->request->get() => NULL,
$_GET => null
$_REQUEST => null
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'' => 'site/index',
'<action:(index|logout|signup|login)>' => 'site/<action>',
]
],
class SiteController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::class,
'rules' => [
[
'actions' => ['error', 'login'],
'allow' => true,
],
[
'actions' => ['index', 'logout'],
'allow' => true,
'roles' => ['@'],
'matchCallback' => function () {
return !Yii::$app->user->isGuest;
},
],
[
'actions' => ['signup'],
'allow' => true,
'roles' => ['?'],
'matchCallback' => function () {
return Yii::$app->user->isGuest;
},
]
],
]
];
}
public function actionIndex()
{
............
}
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
'view' => '@app/views/site/error.php'
],
];
}
}
Answer the question
In order to leave comments, you need to log in
I noticed that without urlManager everything worked fine. I decided to get into the server settings. There was a problem with the correctness of the nginx settings.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question