How to remove .html extension from URL of a static page

About .html extension

HTML is a HyperText Markup Language file format used as the basis of a web page. HTML is a file extension used interchangeably with HTM. HTML is consists of tags surrounded by angle brackets. The HTML tags can be used to define headings, paragraphs, lists, links, quotes, and interactive forms. It can also be used to embed Javascript, and CSS (cascading style sheets).

The current version of HTML as per the W3C (World Wide Web Consortium) is 4.01, though HTML5 is currently in a draft phase. HTML5 implements features like video playback and drag and drop, which have previously relied on third party browser plug-ins such as Adobe Flash and Microsoft Silverlight.

WHAT IS A .HTML FILE?

HTML stands for Hypertext Markup Language, and these HTML files are mostly implemented as static pages of websites. HTML can be used to integrate certain formatting attributes and layout specifications into the content of these Web pages. There are a lot of applications that can be used to create and edit these HTML files, and many Web browsers can be used to open and view the content of files in the .html format. The HTML codes implemented into these .html files are parsed by Web browsers, which means it is hidden from viewers. Microsoft Notepad can be used to create HTML files and also open and view its source code.

HOW TO OPEN A .HTML FILE?

Launch a .html file, or any other file on your PC, by double-clicking it. If your file associations are set up correctly, the application that's meant to open your .html file will open it. It's possible you may need to download or purchase the correct application. It's also possible that you have the correct application on your PC, but .html files aren't yet associated with it. In this case, when you try to open a .html file, you can tell Windows which application is the correct one for that file. From then on, opening a .html file will open the correct application.

How to remove .html extension from URL of a static page

All the pages on the website have a structure which is given by HTML. HTML provides the structure to content, text, tables, headings, and lists on the webpage that makes the page easy to read. While saving an HTML document it has an extension as .html. Therefore, the URL of the website have a .html extension. The .html extension can be easily removed by editing the .htaccess file.

.htaccess file: The .htaccess file is created with a Text Editor like Notepad. It is a simple ASCII file that lets the server know what configuration changes are to be made on a per-directory basis.

Note: The .htaccess is the full name of the file. It is not file.htaccess, it is simply .htaccess.

Removing .html Extension: To remove the .html extension from a URL. For example: 
From  

example.com/content.html

To 

example.com/content

You have to follow these steps: 

Removing Extensions

To remove the .php extension from a PHP file for example yoursite.com/wallpaper.php to yoursite.com/wallpaper you have to add the following code inside the .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

If you want to remove the .html extension from a html file for example yoursite.com/wallpaper.html to yoursite.com/wallpaper you simply have to change the last line from the code above, to match the filename:

RewriteRule ^([^\.]+)$ $1.html [NC,L]
<< Prev Next >>