Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Does every page on a site has to

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
moshelakin
Smarty n00b


Joined: 29 Dec 2021
Posts: 1

PostPosted: Wed Dec 29, 2021 3:26 pm    Post subject: Does every page on a site has to Reply with quote

Hello,

I'm trying to teach myself PHP and Smarty. I'm starting out with something simple: A simple site with just a few pages (home, about, contact, etc.). I have created a template and views for the header and footer and I'm pulling the content dynamically from a MySQL database.

This is a rather simple question but I cannot seem to find an answer:

What is the recommended way to add more pages? Should I have an index.php, then a about.php, a contact.php, etc?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Dec 31, 2021 5:01 am    Post subject: Reply with quote

Commonly accepted modern practice is to have a single entry file, which will catch all requests not served by static content, and route them to appropriate controllers.

Depending on your webserver, here's how you implement it:

Apache httpd:
Code:
<VirtualHost …>
FallbackResource /router.php
</VirtualHost>


nginx:
Code:
server {
    try_files /index.html $uri @app;
    location @app {

        include extras/fastcgi_php_fpm;

        fastcgi_param SCRIPT_FILENAME "/full/path/to/router.php";
        fastcgi_pass …;
    }

}


P.S.
That's no Smarty question, though.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP