Home arrow PHP arrow Search This!

Search This!

Add search capabilities to your site using the popular open source tools PHP3 and ht://Dig.

  1. Search This!
  2. Configuring ht://Dig
  3. Indexing the Site
  4. Building the Search Page
  5. Performing the Search
  6. Displaying the Results
By: Colin Viebrock
Rating: starstarstarstarstar / 24
March 15, 1999

print this article


So, you want to put a "Search This Site" button on your PHP3 sites? Well, unless all your pages are stored in a database (ugh!), there is no easy way to do this using PHP alone.

The solution is to use another program designed specifically for indexing and searching your site, and then use the results of that program in your PHP script.

When I first needed this functionality for a site I was designing for the SummerWorks Theatre Festival, I came across ht://Dig. For those who don't know, "The ht://Dig system is a complete world wide web indexing and searching system for a small domain or intranet. ... [It] is meant to cover the search needs for a single company, campus, or even a particular sub section of a web site."

This tutorial will cover the following steps needed to get these two great Open Source applications working together:

  1. Installing ht://Dig
  2. Configuring ht://Dig
  3. Indexing the Site
  4. Building the Search Page
  5. Performing the Search
  6. Parsing and Displaying the Results

Installing ht://Dig

I'm not going to spend much time on this section, since the ht://Dig documentation can answer any questions much better than I can in this tutorial.

As of this writing, the latest version of ht://Dig is 3.1.0b4. The latest version can always be found at http://www.htdig.org.

Once you've downloaded the archive, and unzipped it, read the README and htdocs/install.html files for the latest information and instructions on how to install. I'm running Linux 2.0.35 and Apache 1.3.3, so your set-up may vary, but the first step is to run the configuration program.

% ./configure

You may then want to edit the CONFIG file. Specifically I changed these four settings to the following values:

prefix =      /usr/local/htdig
CGIBIN_DIR =  /usr/local/htdocs/htdig/cgi-bin
IMAGE_DIR =   /usr/local/htdocs/htdig
SEARCH_DIR =  /usr/local/htdocs/htdig

The last two settings aren't too important, because we're going to be making our own search script and interface using PHP3.

Once the CONFIG file is to your liking, run make and then make install:

% make % make install

If all went well, ht://Dig should be installed and we can move on to configuring it to work with PHP.

>>> More PHP Articles          >>> More By Colin Viebrock

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: