Wednesday, 9 October 2013

Remove .php extension from url using .htaccess

Some websites use to make URL pretty and SEO friendly like www.example.com/home.php to www.example.com/home. So, today in this lesson you will learn how to make your URL pretty and SEO friendly using .htaccess file.








1.Create .htaccess file using any editor like notepad.

2.Save it to your directory like Domain/.htaccess
3.Add the following code in it.


RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)(?:/(.*?)/?)?$ $1.php [L,NC,QSA] //Remove .php extension from url

No comments:

Post a Comment