I was browsing the internet and noticed, YouTube, for example, contains a URL like this to denote a video page: http://www.youtube.com/watch?v=gwS1tGLB0vc
.
When you ask 'Why?' are you asking for a technical reason or a design reason? Some people already answered the technical so I'll just comment on the design.
Basically it boils down to that url is an endpoint. It's a place that users/services need to get to. The extension is irrelevant in most cases. If a user is browsing the web and goes to http://site.com/users he is expecting a list of users. He doesn't care that it doesn't say .html or .php. And as a designer using those extensions doesn't really make sense. You want your app to make sense, and those extensions aren't really providing any insight that the user needs.
Times that you would want to use them were if you were creating a service that other applications would use. Then you could choose to use an extension to denote what kind of data one could expect to get back (.json, .xml, etc). There are people working on design guidelines and specs for this stuff, but it's all early
Basically those extensions are used because that's how web servers/clients worked by default. As web development has matured we started treating urls more professionally and tried to make them make sense to people reading/using them.
There are many possible answers to this. It's how your web application server(s) are configured that results in what your web browser is interpreting. There could be situations where you're using URL rewriting or routing, and as others have said, what handlers you're providing for requested URLs or extensions.
I could have a URL like "http://cory.com/this/really/doesnt/exist" and have it actually be pointing at "http://cory.com/this.does.exist.123" if I wanted to.
While extensions don't matter to the browser, which just uses the headers passed along to it to determine what to display and how to display it, chances are they do matter on the server. For instance, your box could have both a php and a ruby interpreter installed, but your webserver has configuration files to map file extensions to MIME types. For instance, from Apache's php5.conf:
AddType application/x-httpd-php .php .phtml .php3
which tells Apache that files ending in .php, .phtml and .php3 should be recognized as being PHP files.
However, since the extensions don't mean anything to the client, URLs often look "nicer" without them. In order to do so, technologies such as Apache's mod_rewrite can be used to "rewrite" client-land URLs to have meaning on the server.
For instance, you could set up mod_rewrite
rules to rewrite a URL like http://yourblog.com/article/the-article-you-wrote
(which looks nicer and is simpler to type and remember) to http://yourblog.com/articles.php?title=the-article-you-wrote
, which Apache can use to properly route the request to your PHP script.
Having or not having the extension is irrelevant. The browser acts on the MIME type returned by the server, not any extension used in the URL.
The url, should properly be considered part of the user-interface. As such, it should be designed to convey information about where the user is on the site, and the structure of the site.
A url such as:
mysite.com/sport/soccer/brazil_wins_worldcup
tells the user a lot about the structure of the site, and where he currently is. In contrast:
mysite.com/article.php?cateogry=12&articleid=371
is useless, instead it exposes irrelevant implementation-details such as which language is used to make the site, and what the id of that article is (likely stored in a database under that id)
In addition to this estethical argument (don't expose the user to irrelevant implementation-details) it also helps with making the site future-proof. Because if you never exposed your language of choice to begin with, you can later upgrade to Ruby or Python, without every link in the world that points to you, now being a 404.
Design urls to make sense for users, and to be future-proof.
Well, file extensions aren't of any use on the internet. The browser doesn't care what the file extension is. You could serve a CSS file as .avi. So why not simply leave it out? This allows for shorter URLs.
Furthermore "rewriting" a url allows for more readable urls. You may not understand /categories.php?id=455
but you do /455-some-category
.
If you want to do this yourself and are using Apache have a look at mod_rewrite.