title: Adding options to existing .htaccess
body: <p>I have this .htaccess code which I have put together from different sources and I am having trouble adding a couple of extra options to it.</p>
  
  <pre><code>&lt;Limit GET POST PUT&gt;
   order deny,allow
   deny from all
   allow from XXX.XXX.XXX.XXX
  &lt;/Limit&gt;
  
  RewriteEngine On
  
  RewriteCond %{REQUEST_FILENAME} !-f [OR]
  RewriteCond %{REQUEST_FILENAME} !-d
  
  # allow things that are certainly necessary
  RewriteCond %{REQUEST_URI} "/css/" [OR]
  RewriteCond %{REQUEST_URI} "/js/" [OR]
  RewriteCond %{REQUEST_URI} "/images/"
  
  RewriteRule .* - [L]
  RewriteRule ^([a-zA-Z0-9-/_]+)/([a-zA-Z0-9-/_%]+)/([a-zA-Z0-9-/_]+)/([a-zA-Z0-9-/_]+)$  index.php?primary=$1&amp;secondary=$2&amp;tertiary=$3&amp;quaternary=$4 [QSA]
  RewriteRule ^([a-zA-Z0-9-/_]+)/([a-zA-Z0-9-/_%]+)/([a-zA-Z0-9-/_]+)$  index.php?primary=$1&amp;secondary=$2&amp;tertiary=$3 [QSA]
  RewriteRule ^([a-zA-Z0-9-/_]+)/([a-zA-Z0-9-/_%]+)$  index.php?primary=$1&amp;secondary=$2 [QSA]
  RewriteRule ^([a-zA-Z0-9-/_]+)$  index.php?primary=$1 
  </code></pre>
  
  <p>Firstly I would like to add the forced use of <code>www.</code> in the URL.  When I have tried to add this, the resulting URL becomes the output of the current <code>RewriteRule</code>s, containing the <code>GET</code> variables.  I believe this is because the rules work on a loop?</p>
  
  <p>Another thing I would like to do is catch anything that doesnt meet the criteria of the current rules and send that to something like <code>index.php?primary=error</code>.  The way it works now is <em>almost</em> perfect for my use because if there is a malformed URL or illegal character, the site is not going to even attempt to display the page.  The site will create all URLs safely, so any bad URLs would be the result of experimenting in the address bar, but it would be nice to have an error page rather than a <em>page not found</em>.</p>
  
  <p>Thanks in advance.. And sorry for the muddle-through use of <code>RewriteRule</code>!</p>