title: How do I Rewrite the URL for both a specific url condition and a general url condition, using .htaccess?
body: <p>I am working on a website with a custom (basic) CMS system using PHP. The CMS system lives under admin.php and the rest of the site lives under index.php.</p>
  
  <p><strong>// Project explanation for more context on the problem (skip to next comment for the actual problem) //</strong></p>
  
  <p>Both index.php and admin.php takes in GET variables to control the contents of the page. admin.php takes in 3 different GET variables (a, b and c) which defines different funcitonalities. </p>
  
  <p>"A" is for main functionality like "pages - contents of the different pages", "News - Basic blog system" etc.</p>
  
  <p>"B" is sub links specifically for the "pages" functionality to define which page the admin user is modifying. </p>
  
  <p>"C" is also specific for the "pages" functionality and defines the sub-page that the admin user is modifying.</p>
  
  <p>Then the index.php which is the "client-side" of the project takes in two get variables (A and B)</p>
  
  <p>"A" being the page the user is visiting, defined in the database.</p>
  
  <p>"B" being the sub-page the user is visiting, -//-.</p>
  
  <p><strong>// End of project explenation //</strong></p>
  
  <p>So I have been trying to use Rewrite in htaccess to rewrite the URL to a more user-friendly string. </p>
  
  <p><em>(admin.php)</em>
  Example: admin.php?a=pages&amp;b=home => /admin/pages/home</p>
  
  <p><em>(index.php)</em>
  Example: index.php?a=about&amp;b=team => /about/team</p>
  
  <p>And so far the admin Rewrite conditions work perfectly. But I want to implement the client Rewrite conditions, and they collide.</p>
  
  <p>Current .htaccess state:</p>
  
  <pre><code>RewriteEngine On
  
  RewriteRule ^admin/? admin.php [NC,L]
  RewriteRule ^admin/([A-Za-z0-9-&amp;]+)/?$ admin.php?a=$1 [NC,L]
  RewriteRule ^admin/([A-Za-z0-9-&amp;]+)/?/([A-Za-z0-9-&amp;]+)/?$ admin.php?a=$1&amp;b=$2 [NC,L]
  RewriteRule ^admin/([A-Za-z0-9-&amp;]+)/?/([A-Za-z0-9-&amp;]+)/?/([A-Za-z0-9-&amp;]+)/?$ admin.php?a=$1&amp;b=$2&amp;c=$3 [NC,L]
  </code></pre>
  
  <p>I have been looking around on the htaccess documentation and on several questions on stack but havn't been able to find a solid solution.</p>
  
  <p>How can I rewrite the url based on if the user is visiting the admin page or the main (index) page?</p>
  
  <p>Thanks!</p>