SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Distinguishing between directory and file page

  1. #1
    SitePoint Addict svcghost's Avatar
    Join Date
    Oct 2010
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Distinguishing between directory and file page

    Hello guys,

    Having some trouble. Given a URL, how can I use PHP to systematically distinguish between the end portion of a URL being a directory or static file / page, given the following example:

    Code:
    http://us.battle.net/sc2/en/forum/topic/2522432901
    As you can see, there is no period in the end portion of the url, which would signify it being a directory. BUT the page IS a direct page, not a directory. 2522432901 is not a directory. Trying to visit the same URL with a trailing slash at the end succeeds in making a connection, but the page doesn't exist.

    So how can I use PHP to verify that 2522432901 was not a directory, and that the current directory is "topic".

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,109
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    You cannot, the web server can map the URL to any resource it likes.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Addict svcghost's Avatar
    Join Date
    Oct 2010
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Then how can my browser determine it if we can't find a way with PHP?

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,109
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    It doesn't, it just renders what it is presented to it by the web server.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Addict svcghost's Avatar
    Join Date
    Oct 2010
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh I see. Well thank you for your feedback, friend.

    Oh one thing, what exactly is the URL for that page then?
    Code:
    http://us.battle.net/sc2/en/forum/topic/2522432901
    Let's assume it uses PHP for a second. It must have a corresponding .php file that is displaying that info, so how is just a number ("2522432901") sufficing (as opposed to a question mark signifying a variable in the URL like /?2522432901)?

  6. #6
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    The exact URL for that page is http://us.battle.net/sc2/en/forum/topic/2522432901]

    They're probably using mod_rewrite to to rewrite the URL to something like:
    Code:
    http://us.battle.net/sc2/forum/index.php?lang=en&t=2522432901
    Of course, their rewrite rules may be very different than that, and they might very well not be using PHP at all.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •