I do this by passing the entire line after the domain to the index page and processing it in php and not in .htaccess. I am not an .htaccess expert, but this works for me:
RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^.*$ ./index.php
I indicate in the configuration if the site will or will not use lang support, I think that support on the same site can be difficult to implement.
Please ask me if you need more information.
UPDATED
Dennis, I read the @usoban post, and I could say that I have a similar approach. As I said, I get the full path after the domain from .htaccess to my application
class and parse it into an array. If "multilanguage" is specified in config, I take the first element of the array and load the "alias" table for this language.
The table 'alias' is an associative array that displays the alias-controller, for example:
$lang_mods = array( 'home' => 'Home', 'contact' => 'Contact', 'sitemap' => 'Sitemap', 'about' => 'Section/about', 'terms' => 'Section/terms', );
This way I can have a fully translated URL, i.e.
http://www.example.com/en/contact and also: http://www.example.com/es/contacto
So, after removing the first element of the language from the url array, I check the next element on the alias table. The last two elements in the table are special cases that you can use to simplify the URL by getting
http://www.example.com/en/about instead of http://www.example.com/en/section/about this looks better, but both point to the same Section
controller.
After deleting the language and alias, the remaining elements of the -if any- array are passed to the controller. The 'about' or 'terms' in this example are added to the array of arguments. Depending on the controller, the first argument may or may not be an action.
If at some stage of this process something does not match the valid values, it is redirected to the main page.
Well, in your case, maybe if the first argument (or the second, if the site is multilingual) can be checked against the available controllers, if it does not exist, you can redirect to the "standard" controller and then check for available pages in your db . That way, you could avoid having to have an extra /p/
in the url.
I tried to be clear, sorry, English is not my native language;)