100% working site throws errors on production server

Hi folks. My Yii2 site worked perfectly on my local machine, however since I’ve uploaded it to the production server I’m getting some odd issues.

The problem is that, while I can add a record using the system, I can’t delete or even view the record once it’s created. The error is 403 “You are not allowed to perform this action.”

I was using the below ‘access’ rules in my SiteController but I still have the issue even when this section is commented out.




'access' => [

   'class' => AccessControl::className(),

   'only' => ['logout', 'signup', 'create', 'edit', 'index'],

   'rules' => [

	   [

	   'actions' => ['show'],

	   'allow' => true,

		   'roles' => ['?'],

		],

		[

			'actions' => ['index', 'logout', 'create', 'edit'],

			'allow' => true,

			'roles' => ['@'],

		],

	],

],



I can see the main "index" of each view fine, but trying to "view", "update" or "delete" is not working. As I said, "add" works, but then when it takes me to the "view" action after adding, I get the 403.

If anyone can help me get to the bottom of this issue I’d really appreciate it.

from top of my head what I can tell you about your permission error is that your delete, view actions might not be assigned proper roles


// this occurs 

The error is 403 "You are not allowed to perform this action."


//should not you add delete and view in your action whitelist for logged in users like so

'actions' => ['delete', 'view', 'index', 'logout', 'create', 'edit'],

                        'allow' => true,

                        'roles' => ['@'],




as far you namespaces go it really depends how you have you app structured, by looking at the snippet above I assume you are using advanced app structure


backend\models\Regions

it is possible you have your models under common\models\Regions, but this is wild guess I don’t know about your app structure what would be nice if you could paste your model code here and the code that is using the model.

The issue wasn’t a namespace one, it was case-sensitivity as you no doubt would’ve seen right away if I’d pasted my model code. I was referring to backend\Models\Regions instead of backend\models\Regions. Windows tolerated it but Linux wasn’t so lenient :)