Melros
Melros

Reputation: 1213

Is it typical to put all pages in subfolders? Even if it's a single page?

More and more I find websites that show this kind of links:

website.com/page/

and testing if there's in index.php inside the folder like

website.com/page/index.php

I found always true.

So my question:

Is it a common way to put all your pages in subfolders even if it's a single file that you could also easily put in the root folder (in this case page.php) or is there a "common" rewrite for it? If yes, I'd like to know how a typical folder structure for this case would look like.

I just got a bit confused and don't want to do it "wrong" on future projects.

And beside: Does this technique effect SEO?

Upvotes: 0

Views: 1522

Answers (3)

raina77ow
raina77ow

Reputation: 106443

Even if you get some results when you hit website.com/page/index.php instead of website.com/page, doesn't mean there's a file there. In fact, it doesn't mean there's even a folder named 'page': the power of mod_rewrite may easily transform the URL

http://example.com/page/index.php

... into

http://example.com/index.php?controller=page

... so there's a single file executed each time someone queries this application (Single Front-End Controller design). Following this approach makes it not necessary to create a slew of folders for each and every possible user story.

But it's quite true that you should organize your web application into modules (which, in turn, are usually organized as sub-sub-folders of /modules application sub-folder). There's a very popular paradigm - MVC; it's quite commonly used by PHP frameworks and CMS built on this language, but it's not necessary to use one of these to follow it. Perhaps this tutorial might be useful for introducing MVC in PHP to you?

Upvotes: 1

Billy Moat
Billy Moat

Reputation: 21050

If it's a static site then yes it's quite common to have just one page in a subfolder and having that page named as index.html or index.php because most servers are configured to pick that up without showing the filename.

One reason for doing this is so that if future pages are created that would naturally come under that subfolder then it keeps your site structure and site map neat and tidy.

These days many CMS systems replicate this sort of structure on the fly.

For SEO purposes it's good to have descriptive directory names and/or page names i.e.

news/the-title-of-my-news-article.php

Hope that helps.

Upvotes: 1

Madara's Ghost
Madara's Ghost

Reputation: 175007

URIs more often than not have nothing to do with the actual structure of the files. Take Stack Overflow for example: This page's URL is

http://stackoverflow.com/questions/12090658/is-it-typical-to-put-all-pages-in-subfolders-even-if-its-a-single-page

If we follow your logic, it means that stackoverflow has a questions folder for all questions, then a specific ID folder for every single (over 2 million) question, then another folder, with it's complete name, and inside of it an index file.

No, that's not the case. URLs are often rewritten to allow for increased complexity of application.


As for your specific question, perhaps there's a special meaning, perhaps there is none, it's up to the webmaster to decide that.

Upvotes: 1

Related Questions