The steps to remove file extensions are:
- Login to your cPanel account.
- Go to File Manager – in the FILES Section
- In the File Manager go to the Settings button on the top right corner.
- On the Preferences window that will appear check the Show Hidden Files (dotfiles) option. Click Save button to apply the settings.
- Now navigate to the .htaccess file. If the file doesn’t exist you will need to create it.
- Click the Edit button from the File Manager top menu.
- Add the below lines to the .htaccess file. Click the Save Changes button and then the Close button.
#remove php file extension-e.g. https://example.com/file.php will become https://example.com/file RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [NC,L]
- Now the Apache web server will remove .php extension from URLs.
To remove .html extension use:
#remove html file extension-e.g. https://example.com/file.html will become https://example.com/file RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html [NC,L]