Page 1 of 1

Best site structure/architecture for simple php site

Posted: Sat Jul 01, 2006 5:50 pm
by overflowing
I have a static html website with about 20 pages. Just about every page has the exact same html on it with only the content differing on each page. I would like to convert my site to a php based solution so that I can minimize the amount of repeated code on my site and make maintenance and updates easier.

What I would like to know, is there a best practice way to do this? In my search I have come across countless methods, but none seems to stand out, either in my eyes or the eyes of the php community, as being the ideal way to do things.

Two common variations seem to be:
  • Have a single index.php page which processes $_GET variables. In this situation, the user visits the template file and the template pulls in the unique content. Users access the site by typing in URLs such as: http://www.domain.com/index.php?p=somepage.
  • Have many unique content pages which include a header/footer or an entire template. In this situation, the user visits the unique content page and the unique content page pulls in the template. Users access the site by typing in URLs such as: http://www.domain.com/somepage.php
Instinctively, I like the first method better but it's a mild preference. Is one better than the other? Or is there another alternative which is better than both of these?

Re: Best site structure/architecture for simple php site

Posted: Sat Jul 01, 2006 5:58 pm
by tecktalkcm0391
overflowing wrote: [*]Have a single index.php page which processes $_GET variables. In this situation, the user visits the template file and the template pulls in the unique content. Users access the site by typing in URLs such as: http://www.domain.com/index.php?p=somepage.
That way is ok, but Google sometimes will not index anything after the ?, and a bunch of search engines won't. If you wanted to do it that way, I'd use apache and then use mod_rewrite to make it http://www.domain.com/somepage whenever a user goes to http://www.domain.com/index.php?p=somepage. Users like it when the URL is simple so that they don't have to memorize http://www.domain.com/index.php?p=328485 to get to the page they want. Its much better to just see domain.com/page1.

overflowing wrote: [*]Have many unique content pages which include a header/footer or an entire template. In this situation, the user visits the unique content page and the unique content page pulls in the template. Users access the site by typing in URLs such as: http://www.domain.com/somepage.php
This is another option, but I kinda like the other one, but my site is build like this, except certain pages are like the first option. Like on profile pages it has. http://www.domain.com/profiles.php?user=me. Instead of having http://www.domain.com/index.php?p=profiles&user=me

Re: Best site structure/architecture for simple php site

Posted: Sat Jul 01, 2006 6:07 pm
by Roja
tecktalkcm0391 wrote:That way is ok, but Google sometimes will not index anything after the ?, and a bunch of search engines won't.
Not true. All of the major search engines (Yahoo, Google, MSN, and AOL search - collectively over 90% of the search engine visits) support variables in the url. Several years ago, they didn't, but they all do now.

Re: Best site structure/architecture for simple php site

Posted: Sat Jul 01, 2006 6:39 pm
by overflowing
Roja wrote:
tecktalkcm0391 wrote:That way is ok, but Google sometimes will not index anything after the ?, and a bunch of search engines won't.
Not true. All of the major search engines (Yahoo, Google, MSN, and AOL search - collectively over 90% of the search engine visits) support variables in the url. Several years ago, they didn't, but they all do now.
I think in any case, if I chose that option, I would use the apache rewrite module to give user friendly URLs. So I guess that means that we can't prefer one method over the other based on the prettiness of the URL (because they can be made to look the same).