0

I am using nginx and yii2 trying to create a little sample crud rest API, and whenever I enable pretty urls I can't access my routes anmymore.

My config is as follows :

'urlManager'   => [
            'enablePrettyUrl'     => true,
            'enableStrictParsing' => true,
            'showScriptName'      => false,
            'rules'               => [
                [
                    'class'      => 'yii\rest\UrlRule',
                    'controller' => 'user',
                    'only'       => ['delete', 'create', 'update', 'get'],
                    'patterns'   => [
                        'PUT users/<id:\d+>'    => 'user/update',
                        'DELETE users/<id:\d+>' => 'user/delete',
                        'GET users/<id:\d+>'    => 'user/get',
                        'POST users'            => 'user/create',
                    ]
                ],
                [
                    'class'      => 'yii\rest\UrlRule',
                    'controller' => 'campaign',
                    'only'       => ['delete', 'create', 'update', 'get'],
                    'patterns'   => [
                        'PUT campaigns/<id:\d+>'    => 'campaign/update',
                        'DELETE campaigns/<id:\d+>' => 'campaign/delete',
                        'GET campaigns/<id:\d+>'    => 'campaign/get',
                        'POST campaigns'            => 'campaign/create',
                    ]
                ],
            ],
        ],

Note that when enabling this, I can access gii without any issue at /gii instead of /index.php?r=gii

When disabled, my routes work fine using index parameters. Also it's yii giving me 404 and not directly nginx.

EDIT: This url works /user/get?id=1 However this one does not /users/get/1, nor /user/get/1 A POST on /users will work, but not any of the other http requests

Weev
  • 36
  • 1
  • 8

0 Answers0