Force http to https, force www to non-www and remove the file extension for .php on urls
If you are using WordPress then you’ll know that it already removes the .php file extension to give you nice clean urls. And if you’ve used Codeigniter you’ll know you have to stroll into the htaccess to make the urls look normal during setup. Well here I just have a normal website – gasp! – built in php and I needed to do these three things together from the .htaccess file.
Rememeber, this forces www to non-www! Enjoy
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ https://yourdomain.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Need rapid website development:
For smaller projects at high speed
-
Adding script tag embed to Gatsby component
Read More -
Get more than 100 queries in GraphQL (I felt stupid)
Read More -
Animate on Scroll (AOS) into Nuxt js
Read More -
WordPress Super-admin hack
Read More -
Add content or ACF field under thumbnail/image gallery in Woocommerce
Read More