How To Remove PHP And HTML Extension From URL

In this article, we will learn how to remove PHP and HTML extensions from URLs.

The server by default adds an extension in the URL. You can use this step to remove the extension from the URL in any PHP or HTML site.

First, open the file manager using cPanel or FTP.

In the root path finds the .htaccess file.

Some Server hides the .htaccess file by default so You can enable the option in the server to show hidden file.

Still, you can’t find the file then You can create a new file in the root path with this file name .htaccess

Add this code to your .htaccess file.

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

Now extension is removed from the URL. You can check the site URL without an Extension.

Submit a Comment

Your email address will not be published. Required fields are marked *


Select Categories