Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've modified my .htaccess file to allow access to html files without having to include the extension on the end, for example:


directs to


However, when I want to link to pages within my site using something like <a href="page.html"></a> I still get the .html appearing in the URL.

So am I allowed to exclude the extension and leave a link as <a href="page"></a> so that the extension doesn't appear in the browser? Or is there a better way to do it?

share|improve this question
up vote 2 down vote accepted

Yes, make your links match your URLs.

share|improve this answer
Surely this bad practice? If you create a link like <a href="page"></a> how does the browser know how to interpret it? For all it knows, it could be an image file. – Anime163 Jul 6 '12 at 14:38
The browser doesn't know that a .html page is a web page, some are .cgi, some are .php, some are .aspx. The browser requests it, then the server sends the correct MIME type back. – cjk Jul 6 '12 at 14:45
@Anime163 Definitely No. Browser analyse server response headers (Content-Type in particular) as well as actual file content to identify correct format (display/processing method). It is not a surprise to see on the web file with .jpg extension that in fact is .png file (or other way around). If on my site all pages have .do extension -- how browser should treat them (accordingly to your logic)? – LazyOne Jul 6 '12 at 14:45
Thanks for the responses! So if I go through my whole site removing the extensions on the links to html files, that's an acceptable way to do it? – Anime163 Jul 6 '12 at 14:47
Yes, that's fine. – cjk Jul 6 '12 at 15:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.