File Extension & Query String

".htaccess" file is very useful for modifiying file extension and query string.

Removing File Extensions

To remove the .php extension from a PHP file for example mydomain.com/htaccessintro.php to mydomain.com/htaccessintro.

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

Replace php with your file extension, eg: html, htm, asp

Replacing .php ext with .html

when you will access yourpage.html the system will look for: yourpage.php

RewriteEngine On RewriteRule ^(.*)\.html$ $1.php

If you want replace .php ext with .html only for one folder ,you need to put an ".htaccess file" in that specific folder.

myd.com/home.php?page=ajay to myd.com/home/ajay

RewriteEngine On RewriteRule ^home/([a-zA-Z0-9_-]+)$ home.php?page=$1