Search code examples
mysqlcakephp-3.0http-status-code-403

CakePHP 3 Post Method '403 Forbidden'


I came across a really strange issue today and couldn't find any solution. I am using CakePHP 3 along with MySQL and Apache. Everything was working perfect until today but when I tried to edit one of the forum post, it didn't save and I got 403 Forbidden response. Following is the response I got:

Request URL:https://www.example.com/users/edit/2
Request Method: POST
Status Code:403 Forbidden

The strange part is that it is working fine when I try to create new forum post as well as for GET request when I load the edit page. But when I modify the fields and try to save, I get stuck with 403 Forbidden.

I tried every mean in last 6 hours but could not find any solution. I checked database user for edit permissions, tried to remove .htaccess file completely, cleared browser cache and cookies but nothing helped at all. The other websites in hosting account are working fine and there is no issue with them.

The only notable thing I did today is I initialized GIT repository and uploaded project files on git. I would really appreciate your help in solving this issue. It is really a constant headache not to be able to modify anything.


Solution

  • Just for the future reference, I solved this issue by explicitly defining request type to POST in $this->Form->create function.

    It was one of the strangest error I came across while using CakePHP 3! Not sure why default PUT method was not working. It was converting to GET.