How to use .htaccess to remove www, remove the .php file extension, and redirect all to https://


If you're like us, you think www. is outdated/repetitive, file extensions are ugly, and having a secure site is well worth the $12/year, but meshing all these together can be a bit of a hassle, so we'd like to share our most commonly used .htaccess mod_rewrite script.

RewriteBase /
RewriteEngine on
#this part forces non-www
RewriteCond %{HTTP_HOST} !^flwebsites.biz$ [NC,OR]
#this part forces https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://flwebsites.biz/$1 [R=301,L]
#and this part removes php file extensions
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php




Shane Stebner

Author: Shane Stebner

Shane is a successful web-developer specializing in responsive design, and the open-source LAMP stack. Over the years, he's gained in-depth experience with Stripe, Twilio, PhantomJs, Authorize.net, PayPal, Facebook, Twitter, and many other plugins/APIs.


comments powered by Disqus