title: mod_rewrite and GET parameters
body: <p>I have a site which uses pages with the following style:</p>
  
  <pre><code>index.php?page=X&amp;id=Y
  </code></pre>
  
  <p>For example, for a blog it will be </p>
  
  <pre><code>index.php?page=blog&amp;id=65
  </code></pre>
  
  <p>, for a picture it could be </p>
  
  <pre><code>index.php?page=picture&amp;id=26
  </code></pre>
  
  <p>I am trying to set up a rewrite rule such that people can use mysite.com/page or mysite.com/page/id but coming up with issues when passing two parameters.</p>
  
  <p>For some reason, it's redirecting me to the right page and then immediately reloading the same page with no parameters, i.e. it will load <code>index.php?page=blog&amp;id=65</code> and then immediately reload <code>index.php?page=blog</code>, which is useless.</p>
  
  <p>The code I'm using:</p>
  
  <pre><code>Options +FollowSymLinks
  RewriteEngine on
  RewriteBase /
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([^/]+)$ /index.php?page=$1 [L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([^/]+)/([^/]+)$ index.php?page=$1&amp;id=$2 [L]
  </code></pre>
  
  <p>Any suggestions will be appreciated. Thanks.</p>