The usual approach is to redirect everything* towards the main boostrap file of your application usually index.php
.
- When i say everything i mean every URL that is not a file or directory within your public filesystem.
In that way PHP gets the delightful job of parsing the URL and figuring out (dynamically) what page should be rendered and what parameters have been passed.
That's where MVC routers come into place, they have the task of braking the URL into segments and figuring out which of the segments indicate that you should be using a certain controller, which of the segments indicate that the controller should be calling a certain method and which of the segments are parameters that should be passed to the method call.
This approach is used in WordPress for example and the URL parsing is done according to a URL structure you can specify in the admin.
It is also used by CakePHP an MVC framework that allows defaults to the following URL structure: controller_name/method_name/parameter_1:value_1/parameter_2:value_2/
. But can be customized to any extent such as defining a RegEx that extracts the parameters from the URL.
The code bellow is the default .htaccess that WordPress generates.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>