title: Redirect .php to extensionless and make url without .php
body: <p>I dont really know too much about Rewrite in apache, but there is problem with my .htaccess file.</p>
  
  <p>the original .htaccess is </p>
  
  <pre><code>Options +FollowSymLinks
  
  RewriteEngine on
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([a-zA-Z0-9-_.]*)$ /profile.php?id=$1 [L]
  
  
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.php -f
  RewriteRule ^(.*)$ $1.php
  
  # Redirect non-www to www:
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
  
  
  # Unless directory, remove trailing slash
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([^/]+)/$ http://www.domain.com/$1 [R=301,L]
  
  # Redirect external .php requests to extensionless url
  RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
  RewriteRule ^(.+)\.php$ http://www.domain.com/$1 [R=301,L]
  
  # Resolve .php file for extensionless php urls
  RewriteRule ^([^/.]+)$ $1.php [L]
  
  
  ErrorDocument 404 /404.html
  </code></pre>
  
  <p>The first rewrite is for vanity url, another is redirecting non www to www and after that .php to extension less and redirecting .php file to extension less,</p>
  
  <p>Problem i am facing is, if i request www.domain.com/ttt.php and if ttt doesn't exist then it redirects me to <a href="http://www.domain.com/profile?id=ttt.php" rel="nofollow">http://www.domain.com/profile?id=ttt.php</a> 
  Also, i want the rewrite to be for php files not other type, Say if i have ttt.png file and i open www.domain.com/ttt it opens the image rather than showing 404 error.</p>
  
  <p>Similarly happens with other type of files. It opens .txt file first if the names are common.</p>
  
  <p>Thanks for any changes to this, seriously i don't want to mess my site.</p>