I have tried multiple ways of adding CSP and other security measures to my .htaccess, but I was wondering if this is the best way to do this. I can’t seem to even get it working with the .htaccess file.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
@brendonray
You may want to take a look at https://content-security-policy.com/ for examples.
For Apache, you should be able to use the following in either your VirtualHost or
.htaccess
file.There’s also an example by HTML 5 Boilerplate, which is set in the VirtualHost.