Best site structure/architecture for simple php site

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply

Which site structure do you prefer?

Using a template that pulls in unique content (e.g. domain.com/index.php?p=something)
1
33%
Using unique content pages that pulls in template(s) (e.g. domain.com/something.php)
2
67%
Another alternative solution (please post below)
0
No votes
 
Total votes: 3

overflowing
Forum Newbie
Posts: 2
Joined: Sat Jul 01, 2006 5:05 pm

Best site structure/architecture for simple php site

Post 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?
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Re: Best site structure/architecture for simple php site

Post 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
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: Best site structure/architecture for simple php site

Post 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.
overflowing
Forum Newbie
Posts: 2
Joined: Sat Jul 01, 2006 5:05 pm

Re: Best site structure/architecture for simple php site

Post 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).
Post Reply