How to Hide .html Extension from Website URLs (Using .htaccess)

How to Hide .html Extension from Website URLs (Using .htaccess)

This guide explains how to remove the .html extension from website URLs using Apache rewrite rules in the .htaccess file.

After applying this configuration:

Steps to Hide .html Extension

  • Locate the .htaccess file
    Path: public_html/.htaccess
    If the file does not exist, create one

    Add the following rewrite rules

    Add these rules below any existing rewrite rules in the .htaccess file:
    RewriteEngine on
    RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
    RewriteRule ^ /%1 [NC,L,R]
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^ %{REQUEST_URI}.html [NC,L]

  • Save the file
    Save changes
    Clear browser cache or use Incognito mode

 


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 53