PHP - Url rewriting - Asked By ankita on 24-May-11 04:35 AM

Hello,
      I have my static page named services.php.

Now i want to have url rewrite as :

sitename/abc/xyz/test

So how could i do this for static page?


Thanks
Ravi S replied to ankita on 24-May-11 04:39 AM
HI

How it Works

Static URLs are known to be better than Dynamic URLs because of a number of reasons
  1. Static URLs typically Rank better in Search Engines.
  2. Search Engines are known to index the content of dynamic pages a lot slower compared to static pages.
  3. Static URLs are always more friendlier looking to the End Users.



refer the link
http://www.webconfs.com/url-rewriting-tool.php
http://www.daniweb.com/web-development/php/threads/26744
http://blogs.sitepoint.com/guide-url-rewriting/
TSN ... replied to ankita on 24-May-11 04:40 AM
hi..

Examples of url rewriting for seo friendly URL

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 ^product-([0-9]+)\.html$ products.php?id=$1

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