title: create clean url with htaccess
body: <p>I need to generate clean url for my website, and after a week of searching i was able to arrive at this.</p>
  
  <pre><code>RewriteEngine On
  RewriteBase /
  # remove .php extention from web pages
  RewriteRule ^(.+)\.php$ /$1 [R,L]
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^(.*?)/?$ /$1.php [NC,END]
  </code></pre>
  
  <p>the rewrite rule is working perfectly 
  e.g "mysite.com/user.php" result in "mysite.com/user"
  "mysite.com/user/profile.php" result in "mysite.com/user/profile"</p>
  
  <p>Now, the issue I'm having is this;
  when i add query rule like the following</p>
  
  <pre><code># remove .php extention from web pages and query
  RewriteRule ^(.+)\.php$ /$1 [R,L]
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^(.*?)/(.*?)/?$ /$1.php?user=$2 [NC,END]
  </code></pre>
  
  <p>the query works for link like this; <code>mysite.com/user/stephen</code>
  but when i try to visit <code>mysite.com/user</code> again it send me to the 404 page</p>
  
  <p>now these are my aims:</p>
  
  <blockquote>
    <p>1) If someone visit <code>mysite.com/page.php</code> or  <code>mysite.com/page</code> it should
    display <code>mysite.com/page</code> </p>
    
    <p>2) I should be able to query the stephen data
    from <code>user.php</code> with this link <code>mysite.com/user/stephen</code> without having
    previous issue i'm trying to solve</p>
  </blockquote>
  
  <p>thanks in advance, Stephen.</p>