location / {

   if (!-e $request_filename) {
      rewrite ^/(.*)$ /index.php/$1 last;
   }  
}

location /m/ {

   if (!-e $request_filename) {
      rewrite ^/(.*)$ /m/index.php/$1 last;
   }  
}

RewriteEngine on
RewriteCond $1 !^(index.php|js|css|image|robots.txt|favicon.ico)
RewriteRule ^(.*)$ index.php/$1 [L]

RewriteEngine on
RewriteCond $1 !^(index.php|cms|image|js|css|font|m|video|lp|cpn|robots.txt|favicon.ico)
RewriteRule ^(.*)$ /m/index.php/$1 [L]