How to Remove the Page File Extension From the URL

In this post I will show you how to remove the page file extension from the URL..

For example, you want to access the page instead of

The process to remove the file extension is pretty easy. Just follow the instructions bellow.

First, from your website root, you need to access the file “.htaccess”. To do so, most of the web hosting hide such a file. Therefore, we need to learn how to access that file and make visible. Follow the steps bellow:-

1- Go to your website root.

2- Click on the settings button, and select show hidden files:

3- Select the “.htaccess” file and hit edit:

4: Now after you click edit, the file show open in editing mode. So, you need to add the following code:

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

The above code explanation:

So, the first line is to allow the server to rewrite the “.htaccess” file and modify the server setting.

The second, line, is to allow the server request the desired file name and apply the other lines to it.

After the second line, we start to explain to the server that when someone wants to access the “index.php” for example, they can only write “index”. The second line is as same as the previous one. However, the extension is different. It is .html.

The last line is as same order as the previous two lines, but this one allows users to access any file with any extension whether they write the extensions or not.

Lastly, I hope you find this article helpful. I will see you in another article.

.htaccess | file extension | modifying server | page extension | web

Leave a Comment

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

Shopping Cart