Hello friends, welcome to my another blog post how to remove the file extension from URLs using htaccess file. If you want to make your website URLs more user and search engine friendly then it is very important to remove file extension like .php, .html, .htm from your site URL. In this blog post I will show you how to remove file extension from URLs using htaccess.

About .htaccess file

A .htaccess file is a simple ASCII file that you create with a text editor like Notepad or TextMate. It provides a way to make configuration changes on a per-directory basis.This file allows you to enable or disable directives over the whole site, like rewriting URLs, blocking users, controlling cache, and protecting the password, etc. As thus, by overriding some security-related settings, you can safeguard your site effectively.



What .htaccess file can do

1. Redirect the user to different page
2. Password protect a specific directory
3. Block users by IP
4. Preventing hotlinking of your images
5. Rewrite URIs
6. Specify your own Error Documents
7. Disable/Enable built-in PHP functions

How to to remove file extension from urls using htaccess

Let’s take an example of http://example.com/about.php. To remove the .php extension from a PHP file and change it to http://example.com/about Follow these step :

Open .htaccess(create a new one if not exists) file from the root of your website, and add the below code.

To remove the .html extension from a HTML file for example http://example.com/about.html to http://example.com/about Follow these step :

Open .htaccess(create the new one if not exists) file from the root of your website, and add the following code.

That is all. Now you know how to remove the file extension from URLs using htaccess file. Please comment below if you face any issue. Thank you for your time.

Reference URL

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Remove File Extension from URLs using Htaccess
Tagged on: