I need to 301 redirect requests to files with no extension to same with appended .html extension:
http://www.mydomain.com/this
to
http://www.mydomain.com/this.html
The following would not get redirected:
http://www.mydomain.com/that/ (it's a directory)
http://www.mydomain.com/other.php
Any help appreciated on the above, thanks.
Try the following. I would place it as the last rule in your set (i.e. the bottom) to not conflict with any other rules.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\..+$
RewriteRule ^(.*)$ /$1.html [R=301,L]
This should ensure the request is not a directory and that is doesn't end with some kind of extension. If those conditions are met, it will append the request with .html.
This is untested, so comment back if it works. ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With