Hide php extension from url via htaccess




Before URL:  https://domainname.com/about-us.php

After URL:  https://domainname.com/about-us

    RewriteEngine On    
    RewriteCond %{REQUEST_FILENAME} !-d    
    RewriteCond %{REQUEST_FILENAME} !-f    
    RewriteCond %{REQUEST_FILENAME}.php -f    
    RewriteRule ^(.*)$ $1.php [L]    

This will not remove the PHP extension automatically from the URL. You need to remove yourself you'll not get any error.  

Comments