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:

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”.

You cannot, the web server can map the URL to any resource it likes.

Then how can my browser determine it if we can’t find a way with PHP?

It doesn’t, it just renders what it is presented to it by the web server.

Oh I see. Well thank you for your feedback, friend. :slight_smile:

Oh one thing, what exactly is the URL for that page then?

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)?

The exact URL for that page is [http://us.battle.net/sc2/en/forum/topic/2522432901]](http://us.battle.net/sc2/en/forum/topic/2522432901)

They’re probably using mod_rewrite to to rewrite the URL to something like:

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.