Using Show
If you are looking at Server level changes, Below are the rules for .htaccess file View Discussion Improve Article Save Article View Discussion Improve Article Save Article 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.
Removing .html Extension: To remove the .html extension from a URL. For example: example.com/content.html To example.com/content You have to follow these steps:
HTML
You can now link any page inside the HTML document without needing to add the extension of the page as no extension will be visible now in the URL of the website. Example: <a href="http://example.com/image" title="image">image</a> The search engine may index these pages as duplicate content, to overcome this add a <canonical> meta tag in the HTML file. Example: <link rel="canonical" href="https://example.com/blog/first-blog" /> I was recently asked how to remove the HTML extension from a URL on a webpage. I provided some quick advice on how to do this, but thought it would be good to write a post on how to do it. If you don’t know what I’m talking about here, it’s when you visit a website and the URL looks something like this – There are a couple of ways to remove the HTML extension from a URL, so let’s go through a couple of them, shall we? To help me along, I’ve spun up a quick test site using Simple.css. It looks something like this: Notice the URL in the address bar – Ahhhhh my eyes! 🤮 Look at that horrible mess! Solution 1 – Put pages in foldersThe test site I’ve made is currently flat and has no folder structure. So it looks like this:
In order to change
After making that change, let’s revisit the about page and see what’s happened to the URL: Look at that URL, folks! There’s no file extension to be seen. Can we just bask in the glory of what we have accomplished for a second here please? This is how many static site generators, like Jekyll, generate their pages. Everything is in its own sub-folder and therefore have no file extensions in sight. So, basking complete; we’re feeling good. Our mojo is strong and all is well in the world. Well, all is well if you only have a couple of pages on your website. What if you have a blog with tens, or even hundreds of pages? It may not be feasible to restructure your entire site to remove the HTML extension from your URLs. Solution 2 – remove the HTML extension with a .htaccess redirectAn alternative solution is to use your web server’s .htaccess file in order to remove the file extension from the URL. This is done very simply in just a few lines of code:
What this snippet of code is doing, is stripping out ConclusionThat’s it, we’re done! With either of these solutions you should be able to remove the HTML extension from all of your URLs and rid yourself of all that ugliness. Per my disclaimer, this is just how I’ve managed to accomplish this myself. Do you have a better way? If so, please let me know. If you’re hosting your site with Netlify, you could cut out this process completely and use their in-built option for removing file extensions. This post by Ryan Moore shows you how. Can I remove .html from URL?html extension can be easily removed by editing the . htaccess file.
Why does my URL have HTML at the end?. html extension means that page contains only front-end code and does not have any server side language included in it (I'm not talking about URL rewriters that adds .
|