title: .htaccess redirect all extension to php
body: <p>I recently updated my <strong>.htaccess</strong> file to hide the <em>.php extension</em> of the urls. It works nice, when I try to reach <em>domain.com/index</em>, it displays the php file.</p>
  
  <p>When I type <em>domain.com/index.php</em> it redirects me to the <em>domain.com/index</em> url and displays the .php file as well.</p>
  
  <p>I would like to redirect all other extensions to the no extension url to display the .php file for security reasons. My problem is, that I can not configure my <strong>.htaccess</strong> to redirect well known extensions like <em>.html .asp. aspx .shtml</em> etc. to the non-extension url, and get the .php file displayed as the content.</p>
  
  <p>My .htaccess file looks like this:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteBase /
  
  # php extension to no extension url
  RewriteCond %{THE_REQUEST} ^[A-Z]+\s.+\.php\sHTTP/.+
  RewriteRule ^(.+)\.php $1 [R=301,L]
  
  
  # no extension to the .php file
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteCond %{REQUEST_URI} !/$
  RewriteRule (.*) $1\.php [L]
  
  # this is for the index
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  &lt;/IfModule&gt;
  </code></pre>