An alternative (& standard [MVC / Front controller Patterns]) way to handle mod_rewrite rules and rewriting is to pass the whole url to your index.php and then process it there.
It actually makes it simpler in the long run, otherwise the complexity of your problems will only increase as you add more features.
As it seems you are using folders (menu|admin)
with an index.php in each, you have no kind of router script.
So you will need to handle the basic route in the .htaccess
. You basically just need a rewrite for each folder.
The .htaccess goes in your root. Else you would need a rewrite for each folder and without the RewriteBase /path
Directory Structure (Where to put the .htaccess, in root):
ROOT>/
/index.php
/.htaccess
/admin/
/index.php
/menu/
/index.php
/someOtherFolder/
/index.php
/somefile.php
The .htaccess rewrite
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin/menu/(.*)$ admin/index.php?route=$1 [L,QSA]
RewriteRule ^menu/(.*)$ index.php?route=$1 [L,QSA]
Then within your index.php files you handle the route, by exploding the $_GET['route']
param by /
<?php
if(isset($_GET['route'])){
$url = explode('/',$_GET['route']);
//Assign your variables, or whatever you name them
$m = $url[0];
$o = $url[1];
$token = $url[2];
}else{
$m = null;
$o = null;
$token = null;
}
?>
Hope it helps.