Monday, 8 June 2015

In order to make URLs more user and search engine friendly it is important to remove .php extention from URL. In this article we will show you how to remove .php extention from URL. It is very easy to implement using .htaccess file modification.


What is an .htaccess file

 

web developmentFull form of  .htaccess is hypertext access, It is a configuration file which stores server directives and allows decentralized management on a web server. This file allows you to enable or disable directives over the whole site, like rewriting URLs, blocking users, controlling cache, and protecting password, etc. As thus, by overriding some security-related settings, you can safeguard your site effectively.

It is a simple ASCII file by which you can alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software. this file can be created using text editor like Dreamweaver, Notepad or Textmate by giving the extention .htaccess.
Remember that .htaccess is only extention like .php or .html extention. Do not define like file.htaccess or abc.htaccess. Simply name it .htaccess . 

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 hot linking of your images
5. Rewrite URIs
6. Specify your own Error Documents
7. Disable/Enable built-in PHP functions

How to remove Extensions

 

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

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

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
To remove the .html extension from a html file for example yoursite.com/about.html to yoursite.com/about Follow these step : 

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

Regards : PHP Web Development Company

0 comments:

Post a Comment

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube