Request PUT 403 Forbidden

API development using laravel.

Getting 403 Forbidden in a PUT request.

It works on a remote server, but not locally. Using MAMP for the local server.

Here is my virtual host, I do not see anything.

<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot "/Users/dg/Documents/Websites/domain.com/public_html/dev/public_html" ServerName domain.local ServerAlias www.domain.local <Directory /> Options Indexes FollowSymLinks AllowOverride All </Directory> ErrorLog "/Users/dg/Documents/Websites/domain.com/public_html/dev/error_log" CustomLog "/Users/dg/Documents/Websites/domain.com/public_html/dev/access_log" common </VirtualHost>

I looked at other similar questions on SO, but haven't decided yet.

+4
source share
3 answers

Found a solution here: https://serverfault.com/questions/275512/put-request-results-in-403-forbidden-need-apache-to-allow-put-requests

Added the following to .htaccess in the document root:

<Limit GET POST PUT DELETE HEAD OPTIONS> Order allow,deny Allow from all </Limit> <LimitExcept GET POST PUT DELETE HEAD OPTIONS> Order deny,allow Deny from all </LimitExcept>

+9
source

In my Vhosts file, I put:

RewriteCond %{REQUEST_METHOD} !^(HEAD|GET|POST|PUT)$ [NC]

It allowed me to. I tried all the other solutions, and nothing worked except for this.

0

@drack .htaccess, :

    <Limit GET POST PUT OPTIONS>
        Require all granted
    </Limit>
    <LimitExcept GET POST PUT OPTIONS>
        Require all denied
    </LimitExcept>

.htaccess:

Header add Access-Control-Allow-Origin: "*"
Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
Header add Access-Control-Allow-Headers: "Content-Type"
<Limit GET POST PUT OPTIONS>
    Require all granted
</Limit>
<LimitExcept GET POST PUT OPTIONS>
    Require all denied
</LimitExcept>
# BEGIN WordPress
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# END WordPress

And error 403 disappears in the put request.

0
source

All Articles