When using Yii, the following conditions occur,
Use on the template page
">退出后台
After parsing the page generated code URL address is localhost/yii2/backend/index.php?r=site/logout, the address is right, when the visit appears as follows:
Method Not Allowed (#405) Method Not Allowed. This url can only handle the following request methods: POST. The above error occurred while the Web server was processing your request. Please contact us if you think this is a server error. Thank you.
Excuse me, why does it appear 405? Where is the wrong configuration? No routing is configured inside the configuration file
It is possible to find the foreground through Firebug, and it is a post submission. And the URL-generated access is wrong? Help
Reply content:
When using Yii, the following conditions occur,
Use on the template page">退出后台
After parsing the page generated code URL address is localhost/yii2/backend/index.php?r=site/logout, the address is right, when the visit appears as follows:
Method Not Allowed (#405) Method Not Allowed. This url can only handle the following request methods: POST. The above error occurred while the Web server was processing your request. Please contact us if you think this is a server error. Thank you.
Excuse me, why does it appear 405? Where is the wrong configuration? No routing is configured inside the configuration file
It is possible to find the foreground through Firebug, and it is a post submission. And the URL-generated access is wrong? Help
The verbs of site/logout
This action must be configured, and it is clear that this action only accepts requests sent through post!
So you check if the behaviors under Sitecontroller is configured.
'verb' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['post'], ],],
If get access is allowed, then it can be changed to:
'verb' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['get'], //当然可以是是 ['get', 'post'],同时支持POST和GET两种方式访问 ],],