.htaccessmod-headers

Internal Server Error when add Header set Access-Control-Allow-Methods to Htaccess


I would like to add an authorization to my web site through htaccess.

I added this code :

 # BEGIN Cache-Control Headers
<ifmodule mod_headers.c>
 Header set Access-Control-Allow-Origin: https://www.example.com
 Header set Access-Control-Allow-Headers: Special-Request-Header
 Header set Access-Control-Allow-Credentials: true
 Header set Access-Control-Max-Age: 240
</ifmodule>
 # END Cache-Control Headers

But the website give Internal Server Error when I try to add the line below :

 Header set Access-Control-Allow-Methods: PUT, POST, OPTIONS

A special authorization is required or it is a syntax error ?


Solution

  • Try with "":

    Header set Access-Control-Allow-Methods "PUT, POST, OPTIONS"