title: Implement Content Security Policy using local htaccess file (Apache)
body: <p>I'm new to web dev and want to implement Content Security Policy on a certain web page only.</p>
  
  <p>This is what I have done so far: 
   1. Set header this way:  </p>
  
  <pre><code>Header set Content-Security-Policy "
      default-src 'self';
      script-src 'self';
  " 
  </code></pre>
  
  <ol start="2">
  <li>Got a 500 internal server error after this setting. Read somewhere that mod_headers must be enabled. So enabled it using: </li>
  </ol>
  
  <blockquote>
  <pre><code>sudo a2enmod headers
  sudo service apache2 restart
  </code></pre>
  </blockquote>
  
  <ol start="3">
  <li>.htaccess looks like this now: </li>
  </ol>
  
  <blockquote>
  <pre><code>&lt;IfModule mod_headers.c&gt;Header set Content-Security-Policy "
  
      default-src 'self';
  
      script-src 'self';
  
  "&lt;/IfModule&gt;
  </code></pre>
  </blockquote>
  
  <p><strong>Right now, the problem is that I'm not getting any error now but the header is still not set. Please advise me if I'm missing something.</strong> 
  I've gone through other threads already and followed this whole path using:
  <a href="https://stackoverflow.com/questions/28715989/how-to-implement-content-security-policy">How to implement content security policy?</a> 
   and some other questions too. 
  P.S I'm using Apache and PHP on Ubuntu 14.04</p>