0

How could I achieve this?

force load extension via .htaccess ".html" after a url?

Pretty simple, but I couldn't find something a stack article on this or something similar to tweak accordingly.

If someone visits Domain.com/about I want them to land on Domain.com/about.html

Simply put I want to force all url's to load .html after the url via .htaccess.

This is to cover visitors, etc. with old links that don't have .html at the end of the url.

Fearless Mode
  • 241
  • 3
  • 13

2 Answers2

1

Does this page helps you: https://www.garron.me/en/bits/add-html-extension-nginx-apache-htaccess.html

Or take a look here, you can find a bunch of propositions.

Community
  • 1
  • 1
DFayet
  • 881
  • 1
  • 11
  • 21
  • Thanks for this. This does help. It leads to to further think that there is something else missing. The rule you linked me to is similar to what I was using when force loading .css to load .css.gz. When I did that there was a little extra snippet I found to make this work. So that is what I think I need this time around. So thanks. I will further test this out as to why these aren't working for me and what else I may need. Make take me a little while but when I find it I will post/update back. – Fearless Mode Jun 22 '15 at 00:29
1

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643