You are talking about rewriting url, and there are many other questions about this here if you are looking for this term.
Regardless of the fact that URL rewriting is not handled by PHP, this is done by the web server. If you use PHP under Apache, then you might want to take a look at mod_rewrite. For IIS, you have a look at the IIS Rewrite module (which can also import mod_rewrite rules from apache)
source
share