How to organize your page in php?

I usually have a main page (index.php) that includes the header / footer / menu and the content of the page. The content is changed by checking some variable from the GET / POST method: for each condition I load the requested page.

Sort of:

website/
website/index.php?explore=forum
website/index.php?explore=users
website/index.php?explore=articles

etc.

Now my site is growing, and I think the best way is to name the "index" page directly for each section; so for example above it will be traslate like:

website/
website/forum/
website/users/
website/articles/

which looks better and more convenient to manage! The problem is that if I do this, I need to implement a path for each zone (including header / footer / menu).

Therefore, I do not know if there is a better strategy and if it is convenient. Any suggestions and opinions are welcome! Thanks

+3
4

, PHP ( - , Symfony - ), , .

, . .

<?php include('../includes/head.php'); ?>

. , / ,

<?php include('head.php'); ?>
+1

, apache. , /forum , www.yoursite.com/index.php?article=forum ..

: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

+2

MVC, ​​ Symfony (PHP), Rails (Ruby) Django (Python).

MVC -, . , , , . , .

, ( , , , ) .

+2

htaccess, URL- index.php.

, URL- (website/forum/, website/users/ ..) (website/css/, website/images/ ..)..).

:

  • website/[pagename]/ website/page/[pagename]/. URL-, ^/?page/[\w+]/?$ index.php?explore=[pagename]
  • , ; , ^/?[forum|users|articles]/?$
  • Do not worry about it. If you redirect only URLs that do not include the file name, then when you try to link to CSS or images (for example, URLs that contain the file name), this should not be a problem.
+2
source

All Articles