PHPBuilder - Revisited: Build Dynamic Pages With Search Engines in Mind



RSS Twitter
Articles Tricks And Hacks

Revisited: Build Dynamic Pages With Search Engines in Mind

by: Tim Perdue
|
July 30, 2000

When I first wrote this column back in January 1999, I had no clue that it was going to be so wildly popular, and I had even less of a clue that PHPBuilder was going to take off and become as widely-used as it is today.
Since this topic seems to be so important to a wide range of developers, I'll revisit it in more detail, sharing more bits of code with you.
Almost any developer knows that search engine placement is critical to the success of a web site. What many people don't know is that a lot of search engines cannot index many database-driven pages (basically any page with a '?' or '&' in the URL).
So when I set about building gotoCity.com, one of my goals was to make the site database-driven, but still indexable. I didn't want any use of cookies or mile-long URLs, and I wanted useful, context-sensitive meta tags to be generated from every page quickly and with no effort on my part. More importantly, the method shown here actually works. My Gotocity.com web site was getting up to 150,000 page views per day just from search engines alone. That's more than enough to crush a web server.
To pull this off, I started with a subtle Apache feature that can "force" a script to be called for any certain directory tree. In my case, I wanted all URLs that fall under "/local/" to call a script. This would be MUCH easier than creating 200,000 localized web pages and a genuine directory structure to match it.
So in Apache's httpd.conf file, I added the following lines:
<Location /local>
ForceType application/x-httpd-php3
</Location>
This forces every request that starts with "/local/" to call a script called "local" (just "local", not "local.php3") in the $DOCUMENT_ROOT (usually called "/htdocs/") of your server. "local" then uses PHP to parse the URL and act accordingly. The code for my "local"" script is on the last page of this article. You can of course replace "local" with any filename you want, as long as you change your httpd.conf accordingly.
Now if you don't have access to your httpd.conf file, you can also try the <files > directive in a .htaccess file. Hundreds of people ran into this stumbling block in the past 16 months. It appears that this method only works on Linux, as people are reporting trouble on FreeBSD and Windows. If you find an .htaccess solution on Windows, let me know.
Sample .htaccess file:,/div>
<Files local>
ForceType application/x-httpd-php3
</Files>

1
|
2
|
3
|
4
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Tim Perdue

Comment:



Comment:

(Maximum characters: 1200). You have characters left.