Changing file extensions on allpages

I’m having a hard time finding info on putting a 301 redirect into the htaccess file for rediecting all .shtml pages to their new .html counterparts.

There are way too many pages to redirect each one individually so is there a way to handle all of the redirects with one htaccess entry?

I’m not sure I understand this correctly, or if you understood my problem correctly…

A lot of years ago I created my site and have not the time to update it for many years.

I originally used inc files that required the use of an .shtml file extension - so all pages end in .shtml

I now want to recode the site all .html extensions, so…

document1.shtml (etc) will become document1.html (etc)

Then do exactly what I suggested, but swap the .shtml and .html around :cool:

Try this … it will check for a .shtml file, and if not found, will revert to .html

#   backward compatibility ruleset for 
#   rewriting document.html to document.shtml
#   when and only when document.shtml exists
#   but no longer document.html
RewriteEngine on
#   parse out basename, but remember the fact
RewriteRule   ^(.*)\\.html$              $1      [C,E=WasHTML:yes]
#   rewrite to document.shtml if exists
RewriteCond   %{REQUEST_FILENAME}.shtml -f
RewriteRule   ^(.*)$ $1.shtml                   [S=1]
#   else reverse the previous basename cutout
RewriteCond   %{ENV:WasHTML}            ^yes$
RewriteRule   ^(.*)$ $1.html