When using Yii, the following situations occur: Use & amp; lt; ahref & quot; & amp; lt ;? Url: toRoute (& #039; sitelogout & #039 ;);? & Amp; gt; & quot; & amp; gt; exit the Background & amp; lt; a & amp; gt; after parsing, the URL of the code generated on the webpage is localhostyii2backendindex. php? Rsitelogout,... the following occurs when using Yii,
On the template page, use
"> Exit the background
After parsing, the URL of the code generated on the webpage is localhost/yii2/backend/index. php? R = site/logout. The address is correct and the following occurs during access:
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.
Why is 405? Where is the configuration incorrect? No route is configured in the configuration file.
Firebug found that the front-end is acceptable, and it is POST submission. But is the access generated through the url incorrect? Help
Reply content:
When using Yii, the following situations occur,
On the template page, use"> Exit the background
After parsing, the URL of the code generated on the webpage is localhost/yii2/backend/index. php? R = site/logout. The address is correct and the following occurs during access:
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.
Why is 405? Where is the configuration incorrect? No route is configured in the configuration file.
Firebug found that the front-end is acceptable, and it is POST submission. But is the access generated through the url incorrect? Help
Configurationsite/logout
The verbs of this action indicates that this action only accepts requests sent through POST!
Therefore, check whether behaviors under siteController is configured.
'verb' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['post'], ],],
If GET access is allowed, you can change it:
'Verb' => ['class' => VerbFilter: className (), 'actions' => ['logout' => ['get'], // of course, it can be ['get', 'post'], and both post and get methods are supported],],