RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]


# Rewrite /foo/bar to /foo/bar.php

RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]

# NOTE! FOR APACHE ON WINDOWS: Add [NC] to RewriteCond like this:

# RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$" [NC]
# php -- BEGIN cPanel-generated handler, do not edit
# This domain inherits the “PHP” package.
# php -- END cPanel-generated handler, do not edit

