Quick Search

url rewriting for seo friendly URL, Convert .php to .html

July 26th, 2010 by admin
Leave a reply »

 

For rewriting the URL, you should create a .htaccess file in the root folder of your web directory. And have to put the following codes as your requirement.


Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [nc]



The following example will rewrite the test.php to test.html i.e when a URL like http://localhost/test.htm is called in address bar it calls the file test.php. As you can see the regular expression in first part of the RewriteRule command and $1 represents the first regular expression of the part of the RewriteRule and [nc] means not case sensitive.


Options +FollowSymlinks
RewriteEngine on
RewriteRule ^item-([0-9]+)\.html$ item.php?id=$1



The following example will rewrite the item.php?id=5 to item-5.html i.e when a URL like http://localhost/product-5.html calls item.php?id=5 automatically.

Posted in PHP Development

You can follow any responses to this entry through the RSS 2.0 Feed. You can leave a response , or trackback from your own site.

1 commentAdd your comment
  1. It’s posts like this that keep me coming back and checking this site regularly, thanks for the info!

 

Leave a Reply

SEO Company India

search engine marketing company India that offers affordable seo services