title: HTACCESS: Dynamic rewrite url with multiple variables
body: <p>I've been working on this for a couple of days now and I'm wondering if anyone could point me in the right direction please... I'm trying to pass two variables in my rewrite.</p>
  
  <p>Unless the given url is a file or directory, I'd like all urls to be dynamically rewritten as follows:</p>
  
  <blockquote>
    <p>example.com/category -> example.com/index.php?p=category<br>
    example.com/category/page ->
    example.com/index.php?p=category&amp;article=page<br>
    example.com/category2/page ->
    example.com/index.php?p=category2&amp;article=page</p>
  </blockquote>
  
  <p>I'm having a hard time trying to turn the following in something dynamic:<br>
  <code>RewriteRule ^category/(.+?)$ ?p=category&amp;article=$1 [L]</code></p>
  
  <p>I'm trying this but it doesnt work:<br>
  <code>RewriteRule ^(.+?)/(.+?)$ ?p=$1&amp;article=$2 [L]</code></p>
  
  <p>...also trying this but it doesnt work either:<br>
  <code>RewriteRule ^(.*)/(.+?)$ ?p=$1&amp;article=$2 [L]</code></p>
  
  <p>I'm trying to avoid putting in the following to make it work:<br>
  <code>RewriteRule ^category2/(.+?)$ ?p=category2&amp;article=$1 [L]</code></p>
  
  <p>Here is the full code:  </p>
  
  <pre><code>Options +FollowSymLinks
  RewriteEngine On
  
  RewriteRule ^category/(.+?)$ ?p=category&amp;article=$1 [L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ ?p=$1 [L]
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>This actually did it for me:</p>
  
  <pre><code>RewriteRule ^([^/]+)(/([^/]+))? ?p=$1&amp;article=$2 [L]
  </code></pre>
  
  <p>Thank you!!
  Andrew</p>