Why are extensions often hidden on URLs?

There are several reasons to remove extensions from URLs:

  • To make the URLs look cleaner
  • To make URLs easier to type
  • To make URLs easier to remember
  • To make URLs more SEO keyword friendly
  • To be able to change technologies -- if you ever want to move your site from one technology to the other, its easiest to do so without users even knowing if there are no extensions on the URLs

Keep in mind that many sites are generated by a content management system (CMS) that would make URLs look like this: /index.php?page=this-is-the-widget-page. That is particularly ugly and has far more cruft than just an extension. Rewriting to remove index.php?page= makes it much better.

Extensions are not needed on the web because servers send the type of document as a header. Web pages are served as text/html, images as image/png or image/jpeg. This lets browsers know how to render the content without using an extension to figure out that the URL contains text, HTML, PDF or image (for more information see the Wikipedia article Internet media type).

Some webmasters choose to use an extension on their URLs that matches this content type. So any text/html document would have a .html extension and any image/png document would have a .png extension. That can help when the URLs are saved to the file system where the meta data about their content type is lost. In most file systems, the program that opens the file is chosen by the extension. So even if a page is served by PHP, some webmasters remove the .php extension, and some replace it by .html.

There is also the question as to whether URLs might be better ending in trailing slash (/) when they have no extension which has a lot of discussion on Stack Overflow.


All web servers have one or more "default files". It's the file that will be displayed whenever a visitor goes to a URL that ends in a slash /, i.e. a folder.

If the default file name on your web server is index.php and a visitor goes to www.example.com/pagename/, they are actually accessing www.example.com/pagename/index.php.

If there is no trailing /, the web server is probably just re-writing the URL to remove it, since it's not necessary. This site, in fact, does that.


This is the type of “cool” URI scheme that I aim for on my own personal website.

Personally, the reason that I started to do so (and probably many more web designer/developers too!) was after reading the article “Cool URIs don't change” – this document was written by the World Wide Web's founding father, Tim Berners-Lee.

In Tim Berners-Lee's famous article, he basically states the same reasons that Stephen Ostermiller has in his excellent answer to this question.

To give a more specific answer to your main question, “Why extensions are hidden in URLs?” Well, I would say that the main reasons for me are:

1. To future-proof the URI:

For example, it might have sounded like a good idea at the time to use a URI like: http://www.example.com/page.pl where the .pl being the file exetension for a Perl script. However, thesedays, most web developers use ASP.NET or PHP for backend-scripting, so eve though today, http://www.example.com/page.php sounds like a better idea, eventually PHP and ASP/ASP.net will become old-fashioned. So a better idea is to just remove the extension altogether.

2. Readability and Memorability:

It is much easier for a “cool” URI to be passed to people verbally, on paper (e.g. adverts, business cards etc.), not to mention easier to remember.

3. “Hackability” *

Although I'd say that the vast majority of users these days probably go through a search engine for everything – I've even seen people who would go to the address bar and type www.google.com, and then use Google to literally type in www.ebay.com! But, I think that if I have a website based on multimedia, the URI http://www.example.com/video hints that the music section can be found under the URI http://www.example.com/audio, and so on. (I still use the address bar to go to websites – I'm fairly “old-school” about that sort of thing!)

*(Oh! “Hackability” – does that word even exist?! Well, it does now!) :-)

4. **Aesthetics: To make them look prettier! (Blame my OCD!)

However, I have noticed by reading through various SEO-related websites, that a lot of webmasers actually append a file extensions to dynamic URIs, e.g.:

The actual URI may be: http://www.example.com/article

However, the webmaster will perform a rewrite to make the URI “look” static, such as: http://www.example.com/article.html

The logic behind this is that basically, a search engine will assign a higher ranking to static pages (which are, apparently, less likely to change). (Although I'm not exactly an expert in SEO, I personally don't buy into this idea myself – I'm guesing that with the kind of minds behind Google and Bing's algorithms, it will take slightly more than a fake file extension to con your way you into SERP pole position!)

For more information on naming URIs, I recommend reading these articles:

Tim Berners-Lee:

  • “Hypertext Style: Cool URIs don't change”

W3C QA Tips:

  • Choose URIs wisely
  • Managing URIs
  • Make readable URIs (Draft)
  • Make readable URIs (Updated Draft)

Brian Kelly (UK Web Focus / UKOLN - University of Bath):

  • “Web Focus: Guidelines for URI Naming Policies”

Hope this helps!