You could use a htaccess if you're using apache to make this work.
the code would be:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+)$ /public/$1.php
Then the url for your home.php would be domain.tld/home
Explanation:
Options +FollowSymLinks
Options FollowSymLinks enables you to have a symlink in your webroot pointing to some other file/dir. With this disabled, Apache will refuse to follow such symlink
RewriteEngine on
Turns on the RewriteEngine :) so you are able to use rewrite conditions and rules etc.
RewriteCond %{REQUEST_FILENAME} !-d
Like an if that checks if the url (i.E. domain.tld/home) is NOT a directory
because then we want to just access the directory and its index.html or .php ...
RewriteRule ^([a-zA-Z0-9]+)$ /public/$1.php
This is the Rule for what to rewrite.
^
This means that we are rewriting withing this folder (the .htaccess should be in the root directory where the public folder is too)
([a-zA-Z0-9]+)$
This checks wether the part of the url (domain.tld/home) the part here would be home contains nothing else than letters a-z A-Z and numbers 0-9 the +
means that the url can have more than one char, the $
signals the end of the "url checker"
/public/$1.php
This is the file the url should link too.
Because we are in the root folder, we need to get to /public and because the url is domain.tld/home $1
is home so it opens /public/home.php but the url stays domain.tld/home
Hope that helps!