Search code examples
phpmysqldatabasesearch-engine

How to Have Search Engines Index Database-Driven Content?


How can I make it so that content from a database is available to search engines, like google, for indexing?

Example:

Table in mysql has a field named 'Headline' which equals 'BMW M3 2005'. My site name is 'MySite'

User enters 'BMW M3 2005 MySite' in google and the record will show up with results?


Solution

  • Google indexes web pages, so you will need to have a page for each of your records, this doesn't mean to say you need to create 1,000 HTML pages, but following my advice above will dynamically / easily provide a seemingly unique page for each product.

    For example:

    www.mydomain.com/buy/123/nice-bmw-m3-2005
    

    You can use .htaccess to change this link to:

    www.mydomain.com/product.php?id=123
    

    Within this script you can dynamically create each page with up-to-date information by querying your database based on the product id in this case 123.

    Your script will provide each record with it's own title ('Nice BMW M3 2005'), a nice friendly URL ('www.mydomain.com/buy/123/nice-bmw-m3-2006') and you can include the correct meta information too, as well as images, reviews etc etc.

    Job done, and you don't have to create hundreds of static HTML pages.

    For more information on .htaccess, check out this tutorial.