Gossamer Forum
Home : Products : DBMan SQL : Development, Plugins and Globals :

search engine friendly db content

Quote Reply
search engine friendly db content
Since so much of my site consists of dynamic content, I'm always looking for ways to be better indexed by the major search engine spiders. Inspired by the search engine friendly templates that GT developed for GForum, I decided to see if I could use mod_rewrite to trick the search spiders into indexing all the records in my database. Turns out this was super easy to do. If anyone's interested, following is a rough outline of how you can accomplish this. You'll obviously need to change all the directory paths and file names so they make sense for your database. For the example, though, let's assume you have a table that contains records on widgets, and that the primary key for that table is 'ID'. We also need to have your search results set up so that passing "detail=1" in the url will get a detailed single record, rather than a loop of all records.

For each table that you want indexed, you need four basic rewrite rules:

Code:
RewriteRule widgets$ /cgi-bin/db/db.cgi?db=widgets&do=home [L]
RewriteRule widgets/$ /cgi-bin/db/db.cgi?db=widgets&do=home [L]
RewriteRule widgets/all-widgets.html$ /cgi-bin/db/db.cgi?db=widgets&do=search_results&mh=25&ID=0&ID-opt=> [L]
RewriteRule widgets/detailed/(.+) /cgi-bin/db/db.cgi?db=widgets&do=search_results&detail=1&ID-opt==&ID=$1 [L]

You then need one additional RewriteRule which will be used for all tables you want indexed:

Code:
RewriteRule db.cgi /cgi-bin/db/db.cgi?%{QUERY_STRING} [NS,L]

Then to get your widget records indexed, you need to change three urls. The url to the main page about widgets needs to be changed to:

http://www.mysite.com/widgets

And then you need to insert a link to "list all" or "browse records" - something that tells the user you'll be serving up all the records in the table.

http://www.mysite.com/widgets/all-widgets.html

Then finally, in your search_results template, when you're looping through multiple returned records, change the links to the individual records to:

http://www.mysite.com/widgets/detailed/<%ID%>

Voila! That should do it.

Now, obviously I'm not really selling any widgets, and my site isn't really at mysite.com. My point is that I've had to change the syntax of the above a bit to make it more generic for this example. It's entirely possible that something got screwed up in the translation. So if anyone tries this out and it doesn't work, that could be the reason. It might just be a matter of tweaking the syntax slightly.

Anyway, don't know if anyone'll be interested in using this idea or not, but I figured it couldn't hurt to put it out there.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Subject Author Views Date
Thread search engine friendly db content hennagaijin 2681 Oct 3, 2002, 3:59 AM
Post Re: [hennagaijin] search engine friendly db content
hennagaijin 2474 Nov 7, 2002, 4:39 AM