title: Trying to make a GET variable invisible in an URL but retain its usefulness using mod_write
body: <p>Good day all,</p>
  
  <p>I am trying to master the ,magic of mod_rewrite and require some advice/help.</p>
  
  <p>I am trying to turn an URL from:</p>
  
  <pre><code>http://www.domainname.com/preview/about/5
  </code></pre>
  
  <p>To this:</p>
  
  <pre><code>http://www.domainname.com/preview/about
  </code></pre>
  
  <p>The issue is, I still need to retain the [id] part of the original URL to be used as a GET later on and it not be visible.</p>
  
  <p>The code I have thus far:</p>
  
  <pre><code>RewriteRule ^preview\/([^/]+)\/([^/]+)\/$         /preview\/$1?id=$2 [R=301,QSA]
  RewriteRule ^preview\/([^/]+)\/$                  ?mode=preview&amp;id=$2 [L,QSA]
  </code></pre>
  
  <p>This manages to create an URL like: <code>http://www.domainname.com/preview/about/?id=5</code> and passes the <code>ID</code> through, I just need the ?id=5 to be invisible in the URL.</p>
  
  <p>Thank you in advance anyone who has a solution for this, much appreciated.</p>
  
  <p>UPDATE:</p>
  
  <p>I have managed to get the following code to work as expected alas this is using static values for ID all I now need for this to be complete is to get it working off dynamic values for ID.</p>
  
  <pre><code>RewriteRule ^preview\/([^/]+)\/([^/]+)\/$       /preview\/$1      [R=301,QSA]
  RewriteCond                                     %{QUERY_STRING} !.*id=5.*$
  RewriteRule ^preview\/([^/]+)\/$                ?mode=preview&amp;id=5 [L,QSA]
  </code></pre>