Tuesday, 7 July 2015

URL shortening : Removing .php - file extension


Most of the times when we are browsing php based website,  there we can see .php - file extensions associated with each page names ( Ex: http://yourdomain.com/about.php ). if you think this make your URL bit ugly, don't worry we can eliminate these extensions from our URL ( Ex: http://yourdomain.com/about ) . Here writing the procedure for removing ".php"  file extensions from URLs where our files are in Apache server.


Follow These steps for removing  ".php"  file extension from URLs

Step 1:
Create a .htaccess file (create a file and save this named " .htaccess").

Step 2:
Open this .htaccess file and paste the below code.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}.php -f

RewriteRule ^(.*)$ $1.php

Step 3:
Save and move this file to the root directory of your website or application.

Step 4:
Done that's it.Now you can use files without extension in your Website.



How to Use the above feature in your existing Website

If you are already using files with .php extension in website (<a href=" http://yourdomain.com/about.php " > About </a> ) then you need to edit all the links appear in page without ".php"   file extension ( <a href=" http://yourdomain.com/about ">About </a>  ) .

0 comments:

Post a Comment

Popular Posts

Categories

browser (1) examples (1) facebook (1) Google (3) How to? (4) html5 (1) Microsoft (1) tutorials (2) VLC (1)

Follow My blog

Contributors

Ajesh VC . Powered by Blogger.