Yii2 url not found while displayed when accessing controller action

I created a controller function like

public function actionRateTicket($id){

}

urlManager has the following configuration

'urlManager' => [
            'class' => 'yii\web\UrlManager',
            // Disable index.php
            'showScriptName' => false,
            // Disable r= routes
            'enablePrettyUrl' => true,'enableStrictParsing' => true,

            'rules' => array(
                    '<controller:\w+>/<id:\d+>'              => '<controller>/view',
                    '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                    '<controller:\w+>/<action:\w+>'          => '<controller>/<action>',
            ),
        ],

But when I tried to access http: // mydomainname / web / ticket / rate-ticket / 2333 , (ticket is the name of the controller (TicketController.php)), it shows an Not Found (#404)error.

What is the problem? I can access all controller actions with single camel characters such as actionView, actionEdit, etc., but actionRateTicket, I can't leave. If actionRateTicket is renamed to actionRate, it works.

My controller is like this

<?php

namespace app\controllers;

use Yii;
use app\models\Techs;
use app\models\Ticket;
use app\models\Assignment;
use app\models\TicketSearch;
use app\models\ComplainType;
use app\models\TicketComplain;
use app\models\User;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use app\models\Adusers;
use yii\web\UploadedFile;
use app\helpers\Utils;
use yii\db\Expression;
use yii\filters\AccessControl;


/**
 * TicketController implements the CRUD actions for Ticket model.
 */
class TicketController extends Controller {
    public function behaviors() {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'only'  => [
                    'index', 
                    'view',
                    'update',
                    'delete', 
                    'newticket'
                ],
                'rules' => [
                    [
                        'actions' => [
                            'index',
                            'view', 
                            'update',
                            'delete', 
                            'newticket'
                        ],
                        'allow'   => true,
                        'roles'   => ['@'],
                    ],
                ],
            ],
            'verbs'  => [
                'class'   => VerbFilter::className(),
                'actions' => [
                    'delete' => ['post'],
                ],
            ],
        ];
    }

    public function actionRateTicket($id) {
        echo "in"; echo $id;
        exit;
    }
}
?>

My .htaccess in web folder

RewriteEngine on

# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
+4
source share
5 answers
+3

:

use yii\helpers\Url;
+3

'access' => [
                    'class' => AccessControl::className(),
                    'only' => ['rate-ticket', 'index','view','update','delete','newticket' ],
                    'rules' => [
                            [
                                    'actions' => ['rate-ticket', 'index','view','update','delete','newticket', ],
                                    'allow' => true,
                                    'roles' => ['@'],
                            ],

                    ],
            ],
0

, - , Yii . <action:\w+> <action:[-\w]+>, !

, , , .

0

yii2 URL-, SEO, . :

UserProfileController
index.php?r=user-profile
0

All Articles