Why don't some websites have a .html extension in their pages?

I’m learning HTML, and I can’t figure out why some websites don’t have a .html extension on their webpage.
Example: no html extension
Example: html extension
Anyone know how I can make it look like that there is no extension? Is it safer than the other method?

I tried creating a file without an html extension, but it only showed text instead of html.

Thanks for any help!

>Solution :

In general, the presence or absence of file extensions in website URLs serves different purposes:

With extensions (e.g., ".html"):

  • Websites with URLs ending in ".html" typically serve HTML files directly to the browser.
  • These URLs indicate that the web server is delivering a specific HTML file to display.

Without extensions:

  • Websites with URLs not ending in any extension may employ URL rewriting or routing techniques to determine what content to show in the browser.
  • Multiple possibilities exist for what’s happening behind the scenes:
    1. The server may still serve an HTML file but hides the extension for cleaner URLs.
    2. The server might dynamically generate content using server-side scripting languages like PHP, Python, Node.js, etc. In this case, there may be no fixed file with an extension.
    3. URL rewriting could be in use, showing a user-friendly URL like example.com/questions/ask while the actual file on the server might be something like show_recent_questions.php. This file extension is not exposed to the browser and neither is the original file name.

The URL ending in .html doesn’t necessarily mean it was a static HTML page, since a rewrite rule could make any dynamic content also end w/ an extension of ".html".

Also as @user3163495 mentions, you can also check the header information for additional details.

Leave a Reply