title: clean URL using .htaccess
body: <p>I'm trying to redirect the links on my domain.
  What I'm trying to achieve is:
  When the user clicks on a link to </p>
  
  <p><code>mydomain.com/index.php?dir=myfolder</code></p>
  
  <p>I want him to be redirected to exactly this URL but the browser bar is supposed to show this URL:</p>
  
  <p><code>mydomain.com/myfolder</code></p>
  
  <p>Since I don't have access to how the links are established (it's a php-site) I am trying to do this with just the .htaccess-file.</p>
  
  <p>This is what I have:</p>
  
  <pre><code>RewriteEngine on
  RewriteBase /
  RewriteCond %{HTTP_HOST} subdomain.mydomain.com
  RewriteCond %{REQUEST_URI} (.*)/style.css [OR]
  RewriteCond %{REQUEST_URI} (.*)/script.js [OR]
  RewriteCond %{REQUEST_URI} (.*)/logo.png
  RewriteRule (.*) http://www.subdomain.com%{REQUEST_URI} [R=301,NC,L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php?dir=$1 [L]
  </code></pre>
  
  <p>So when I enter <code>"mydomain.com/myfolder"</code> into the browser it works fine and the URL in the address-bar stays like this. But when I enter <code>"mydomain.com/index.php?dir=myfolder"</code> it works as well but the URL also stays the same (which is not what I want).
  I assume that I need to somehow change the URL with the .htaccess-file and have it then (as I already have) rewritten to then php-scheme.
  I did several approaches now but I have no idea how to do this.
  I hope you understand my question and can help me!</p>
  
  <p>Thank you!</p>
  
  <pre><code>EDIT:
  </code></pre>
  
  <p>The solution ( thanks to @anubhava):</p>
  
  <pre><code>RewriteEngine on
  RewriteBase /
  
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?dir=([^\s]+) [NC]
  RewriteRule ^ %1? [R=301,L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php?dir=/$1 [L]
  </code></pre>