I am working on building an internal CMS for clients. Instead of creating a new php file for each page, I am wondering if there is a way to load up a page based on the URL but not a physical php file in that location.
So, if I visit http://www.mysite.com/new-page I would like this to just be a reference to my template, content, etc. rather than an actual .php file.
Sorry if I have not explained this correctly, but I am having a hard time explaining it.
Thanks.
Sounds like you need the Front Controller pattern.
Basically every URL gets redirected to one PHP page that determines what to do with it. You can use Apache mod_rewrite for this with this .htaccess:
That redirects everything except static content files to index.php. Adjust as required.
If you just want to affect the URL /new-page then try something like:
Any URLs starting with “new-page” will be sent to myhandler.php.