This question is quite easy and has been asked before.
This is why I will not give you the exact answer, but rather redirect you to tutorials and guidelines explaining you what to do. This'll allow you to understand the solution even better.
If you're running your site on an Apache server, you can use Mod Rewrite.
https://httpd.apache.org/docs/current/mod/mod_rewrite.html
Also check this out:
http://corz.org/server/tricks/htaccess2.php
But as people seem to downvote me because of this, I'll help you out.
In your .htaccess file, you place the following
Whenever you use mod_rewrite (the part of Apache that does all this magic), you need to do before any ReWrite rules. You only need to do this once per .htaccess file.
+FollowSymLinks must be enabled for any rules to work, this is a security requirement of the rewrite engine. Normally it's enabled in the root and you shouldn't have to add it, but it doesn't hurt to do so
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*) page.php?p=$1 [NC]
NC means no-case a.k.a. case-insensitive.
You can also add L (-> [NC,L]) to inidicate this is the Last Rewrite Rule.
You may have noticed, the solution above uses regular expression to match variables. What that simply means is.. match the part inside (.+) and use it to construct "$1" in the new URL. In other words, (.+) = $1 you could have multiple (.+) parts and for each, mod_rewrite automatically creates a matching $1, $2, $3, etc, in your target (aka. 'substitution') URL.