Htaccess - Add .html when needed - Wordpress


Staff member
I want to add .html extension to all pages that are not finishing with this extension. I want to do it when the page with .html exists.
I have tried with a lot of code that I have seen and nothing worked on this sense.Maybe there are something different than htaccess to do this.
The only thing that I got was to put .html extension when the page finishes with /.
The web is make with wordpress so if you know any plugin or something that can do this please tell me :)

My initial code in .htaccess is:

# Do not do anything for already existing files and folders
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]

# add .html file extension (if such file does exist)
RewriteCond %{DOCUMENT_ROOT}/$1\.html -f
RewriteRule ^(.+[^/])/?$ $1.html [L,QSA]

Thanks a lot for your answers!