.htaccess example

This is an example of the .htaccess file I have on the website. It will remove the .php at the end web page in the browser url and will also force https if http is typed in browser or an http link to your site is clicked, assuming you do have a valid ssl cretificate installed.

Remeber to create and save the file as ".htaccess"

                
                    RewriteEngine on
                    #ssl re-direct
                    RewriteCond %{HTTPS} off [OR]
                    RewriteCond %{HTTP_HOST} ^www\. [NC]
                    RewriteRule ^ https://YOUR-WEBSITE.com%{REQUEST_URI} [L,NE,R=301]

                    # Run Php without filename extension - removes .php from webpage in browser url
                    RewriteCond %{REQUEST_FILENAME} !-d
                    RewriteCond %{REQUEST_FILENAME}.php -f
                    RewriteRule ^(.*)$ $1.php
                    # Return 404 if original request is .php
                    RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
                    RewriteRule .* - [L,R=404]