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.
// Project explanation for more context on the problem (skip to next comment for the actual problem) //
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.
"A" is for main functionality like "pages - contents of the different pages", "News - Basic blog system" etc.
"B" is sub links specifically for the "pages" functionality to define which page the admin user is modifying.
"C" is also specific for the "pages" functionality and defines the sub-page that the admin user is modifying.
Then the index.php which is the "client-side" of the project takes in two get variables (A and B)
"A" being the page the user is visiting, defined in the database.
"B" being the sub-page the user is visiting, -//-.
// End of project explenation //
So I have been trying to use Rewrite in htaccess to rewrite the URL to a more user-friendly string.
(admin.php) Example: admin.php?a=pages&b=home => /admin/pages/home
(index.php) Example: index.php?a=about&b=team => /about/team
And so far the admin Rewrite conditions work perfectly. But I want to implement the client Rewrite conditions, and they collide.
Current .htaccess state:
RewriteEngine On
RewriteRule ^admin/? admin.php [NC,L]
RewriteRule ^admin/([A-Za-z0-9-&]+)/?$ admin.php?a=$1 [NC,L]
RewriteRule ^admin/([A-Za-z0-9-&]+)/?/([A-Za-z0-9-&]+)/?$ admin.php?a=$1&b=$2 [NC,L]
RewriteRule ^admin/([A-Za-z0-9-&]+)/?/([A-Za-z0-9-&]+)/?/([A-Za-z0-9-&]+)/?$ admin.php?a=$1&b=$2&c=$3 [NC,L]
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.
How can I rewrite the url based on if the user is visiting the admin page or the main (index) page?
Thanks!