9 Replies - 5135 Views - Last Post: 11 December 2008 - 07:32 PM Rate Topic: -----

#1 Sonastylol  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 151
  • Joined: 15-December 07

Subdirectories on website?

Posted 11 December 2008 - 11:58 AM

Hey everyone! :D

I see a lot of websites nowadays with these subdirectories like:

domain.com/about
domain.com/upload
domain.com/affiliates
..you name it.

1) On public_html, have they created 3 folders named about, upload, and affiliates, and created an index.php/index.html for each folder?


2) My website currently displays entries from a database as domain.com/view.php?file=12345678. I've seen websites such as digg.com that use domain.com/view/story?id=123. How can I make my view.php?file=12345678 become that?

If 2 is too complicated, please help me out with 1 because it is what I most desire.

:^:

Is This A Good Question/Topic? 0
  • +

Replies To: Subdirectories on website?

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3034
  • Posts: 10,597
  • Joined: 08-August 08

Re: Subdirectories on website?

Posted 11 December 2008 - 01:28 PM

The best way to learn things like this is to try them. Create a test index.php file and put it in a subdirectory. What happens when you go to www.yoursite.com/yoursubdirectory?
Was This Post Helpful? 0
  • +
  • -

#3 AdaHacker  Icon User is offline

  • Resident Curmudgeon

Reputation: 452
  • View blog
  • Posts: 811
  • Joined: 17-June 08

Re: Subdirectories on website?

Posted 11 December 2008 - 01:29 PM

You can do this by using mod_rewrite and/or parsing the request URI in code. Here's an article on the subject.
Was This Post Helpful? 1
  • +
  • -

#4 Sonastylol  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 151
  • Joined: 15-December 07

Re: Subdirectories on website?

Posted 11 December 2008 - 01:32 PM

View PostCTphpnwb, on 11 Dec, 2008 - 12:28 PM, said:

The best way to learn things like this is to try them. Create a test index.php file and put it in a subdirectory. What happens when you go to www.yoursite.com/yoursubdirectory?


I know what happens CT, the domain will search for:
* index.html
* index.htm
* default.htm
* Default.htm
* home.html
* Home.chtml
* index.php

If these files are not present, you will be greeted with a message:
Directory has no index file.
Browsing this site or directory without an index file is prohibited.


But is this how all of these companies do that? I mean... having a bunch of index files open in an editor seems like madness, although it can be remedied by "<!-- /ABOUT/index-->"
Was This Post Helpful? 0
  • +
  • -

#5 AdaHacker  Icon User is offline

  • Resident Curmudgeon

Reputation: 452
  • View blog
  • Posts: 811
  • Joined: 17-June 08

Re: Subdirectories on website?

Posted 11 December 2008 - 02:47 PM

View PostSonastylol, on 11 Dec, 2008 - 02:32 PM, said:

But is this how all of these companies do that?

No, they don't. The "standard" method for pretty URLs is to set up your server to direct all dynamic requests to a single, central PHP script. This script will then parse the requested URI, determine the action to take, and call the appropriate module based on that. This is the approach used by most of the popular MVC frameworks (Zend, Symfony, etc.), so you can always look at them for an example.
Was This Post Helpful? 0
  • +
  • -

#6 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 90
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Re: Subdirectories on website?

Posted 11 December 2008 - 02:51 PM

Quote

This is the approach used by most of the popular MVC frameworks (Zend, Symfony, etc.), so you can always look at them for an example.


I was just about to mention that. Anytime you see a site that has a list of directories and then a variable, it's most likely a framework. CakePHP and CodeIgniter are a couple other frameworks that use that method.
Was This Post Helpful? 0
  • +
  • -

#7 Sonastylol  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 151
  • Joined: 15-December 07

Re: Subdirectories on website?

Posted 11 December 2008 - 03:27 PM

Does my website look less professional with /upload.php, /stats.php, /view.php?file=### ?
Was This Post Helpful? 0
  • +
  • -

#8 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 90
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Re: Subdirectories on website?

Posted 11 December 2008 - 03:29 PM

Not at all. It's just different methods of development. You use what's best for you. An unprofessional website would be on that doesn't work. The URL structure shouldn't matter too much.
Was This Post Helpful? 0
  • +
  • -

#9 mocker  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 50
  • View blog
  • Posts: 466
  • Joined: 14-October 07

Re: Subdirectories on website?

Posted 11 December 2008 - 03:53 PM

the url structure can matter. One, it is easier to remember domain.com/stats/ or domain.com/users/username then it is is to remember users.php?username=? or users.php?u=? or .. ect

Two, having keywords in your url helps your search engine ranking.

Three, the rewrites work behind the scene, so if you switch from a users.php file to perl or ruby or rename the file, or move the file, the url doesn't change you just update the mod_rewrite line. To the user this means your urls are reliable, search engines don't find broken links and sites linking to you don't have broken links either.

Considering the pro's I'd suggest using them for any public site.
Was This Post Helpful? 0
  • +
  • -

#10 Sonastylol  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 151
  • Joined: 15-December 07

Re: Subdirectories on website?

Posted 11 December 2008 - 07:32 PM

Wow, you're right. Thanks Mocker.

I will definitely take a look at that tutorial posted above then and try to learn it once I have time (studying for finals :P ;P)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1