title: Apache - remove .php and .html file extensions using mod_rewrite in httpd.conf
body: <p>Running Apache 2 on Ubuntu 14.04. rewrite_module is enabled (<code>sudo apachectl -M</code>).</p>
  
  <p>In /etc/apache2/apache2.conf (the Ubuntu version of httpd.conf) I have the following code block:</p>
  
  <pre><code>&lt;Directory /var/www/&gt;
      &lt;IfModule mod_rewrite.c&gt;
          RewriteEngine On
  
          RewriteCond /%{REQUEST_FILENAME}.php -f
          RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.php
  
          RewriteCond /%{REQUEST_FILENAME}.html -f
          RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.html
      &lt;/IfModule&gt;
  
      &lt;IfModule mod_expires.c&gt;
          ...
  
          &lt;IfModule mod_headers.c&gt;
              ...
          &lt;/IfModule&gt;
      &lt;/IfModule&gt;
  &lt;/Directory&gt;
  </code></pre>
  
  <p>Ran <code>sudo service apache2 restart</code>.</p>
  
  <p>When I visit a url on my server without the .php file extension, I get a 404! Why isn't this working?</p>