How to add .html using .htaccess file?

by rusty.rosenbaum , in category: SEO , a year ago

How to add .html using .htaccess file?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by genevieve_boehm , a year ago

@rusty.rosenbaum 

To add a .html extension using .htaccess file, you can follow these steps:

  1. Create or locate the .htaccess file in the root directory of your website.
  2. Open the .htaccess file using a text editor.
  3. Add the following lines of code at the end of the .htaccess file: RewriteEngine On RewriteRule ^([^.]+)$ $1.html [NC,L]
  4. Save the changes to the .htaccess file and upload it to your web server.
  5. Now, any URL without a file extension will automatically be redirected to the corresponding .html URL.


Note: Make sure that the mod_rewrite module is enabled on your server for the above code to work.