Search engines follow their own set of rules, each one different and rarely do two search engines have the same algorithyms for how they display search results. This includes the major players like Google, MSN, Yahoo, and so on. But to healp make your website URL’s more friendly to most of them, we can deal with an issue of pages that query a database and give us the ‘?’ followed by a series of variables.
So if you have a website that has a database of products, lets use Cheese for example, in the database the products would be identified by an id variable. For one of our products we will use Gouda, which has an in of product 66. When searching on your website or going through products, the existing site displays Gouda based off the id, for example:
http://www.mycheesewebsite.com/product.php?id=66
Of course looking at the URL, and when indexing (search engines) the above example, there is no way to tell what the product is. Also, some search engines will not spider beyond the ?. So how then, do we get the search engine bots to spider the page so it ends up being indexed?
Simple, we use .htaccess and the RewriteEngine protocal to change the URL to something more Search Engine friendly/optimised or SEO, so our webpage looks like this:
http://www.mycheesewebsite.com/gouda-cheese.html
Here is how we accomplish the. There are two steps. One requires modification of your .htaccess file. ( root directory – public_hml ) if for your entire website, or a sub directory ( public_html/cheesestore )
RewriteEngine OnRewriteRule ^(.*)_pr(.*).html product.php?id=$2
<?php
$product = msyql_fetch_assoc(MYSQL RESOURCE YOU CREATED PREVIOUSLY);echo ‘<a href=”‘.convertProductName($product['product_name']).
’_pr’.$product['product_id'].’”>’.
$product['product_name'].’</a>’;
function convertProductName($p_name){
// Takes a string, and returns the same string but with all
// the spaces converted to hypens etc.
}
?>
Test in browser. If you run into problems, check that .htaccess file is saved as a unicode file.