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 managment system (CMS) that would make URLs look like this: /index.php?page=this-is-the-widget-page
That is particularly ugly. It 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 StackOverflow.