title: http redirect with htaccess updating url only
body: <p>working with .htaccess i solved about the url conversion from (for example):</p>
  
  <p>(a) <a href="http://www.mydomain.ext/dir/myfile.php" rel="nofollow">http://www.mydomain.ext/dir/myfile.php</a></p>
  
  <p>to:</p>
  
  <p>(b) <a href="http://www.mydomain.ext/dir/myfile" rel="nofollow">http://www.mydomain.ext/dir/myfile</a></p>
  
  <p>(deleting the .php) to end. But if user from web typing as in (a) them display the url so as typed. 
  How i can solve becouse typing as in (a) webserver display too as in (b) ? 
  I thinked about a redirect from (a) to (b) but not think that it is the best solution, what suggest for solve it?
  Thanks very much for help.</p>
  
  <hr>
  
  <p>ADD THIS:
  Try to explain better the question with a concrete example. Starting from .htaccess i have:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^(.*)$ $1.php
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>and i solved it using PHP so:</p>
  
  <pre><code>$default_url = "http://".$_SERVER["HTTP_HOST"].$_SERVER
  
  ["REQUEST_URI"]; // display something as: http://www.mysite.ext/dir/filename.php
      $canonical_url = str_replace(".php", "", "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]); // display something as: http://www.mysite.ext/dir/filename
      if ( $default_url != $canonical_url ) {
          header( 'Location: ' . $canonical_url, true, 301 );
      }
  </code></pre>
  
  <p>I ask as update the .htaccess code for integrate about feature descripted in PHP script. I have looked much example but not solve it.
  Thanks very much.</p>