Score:0

Apache server .htaccess set header for Content-Security-Policy causes 500 error

kr flag

I am trying to add 2 headers to the .htaccess file but when the site is reloaded it gives a 500 internal server error

First header is:

Header set Content-Security-Policy: default-src https:

According to this website, this should allow any assets to load over https from any origin.

Second header is:

Permissions-Policy: geolocation=(self "https://example.com"), microphone=()

Obviously changing example.com to the proper domain, but the same website says this should work but also causes internal server error.

vidarlo avatar
ar flag
Is mod_headers enabled?
in flag
A 500 error is the webservers way of saying "I have a major problem but I don't want to talk about it in public". Read the error logs of your server. They contain a clear message about the error.
Score:0
ar flag
Header set Content-Security-Policy: default-src https:

Syntax is wrong.

Header set Content-Security-Policy "default-src https:"

Is correct syntax.

In addition you should verify that mod_headers is enabled.

noname avatar
kr flag
Hey, mod_headers is enabled as i have a bunch of others. Thanks for the answer, that fixed it, i also added unsafe-inline. Do you know what may be the issue with permissions-policy? I actually tried Header set Permissions-Policy geolocation=(self "https://example.com"), microphone=() - i removed the colon after policy but still 500 error
vidarlo avatar
ar flag
If it fixed it, please accept the answer. Regarding your other line, read my answer again, and read the manual again. You're using the wrong syntax.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.