This application allows webmasters to highlight search results on their web pages. When a user performs a search using Google, AltaVista or other search engine, then clicks on a link to a website which has the search highlighter installed, all matching search terms in the page are highlighted in yellow. The page will also automatically scroll down to the first match. This makes it much easier for the user to find what they're looking for. Try this example, search for "Neil Fraser" in your favourite search engine. Choose my site, and note the highlighting (if you've recently been to my homepage, your cache may serve an unhighlighted version of the page).
- Double-quoted phrases are supported. If you search for "Neil Fraser" with quotes, it will only highlight those words when they appear together.
- Wildcards. Google and AltaVista support wildcards. So does the search highlighter. A "*" inside a double-quoted phrase will match any single word.
- It works on all browsers and on all HTML content on the whole website, whether it comes from files or CGI scripts. There is no need to make changes to any of the documents or scripts. Instead, it uses a filter on Apache's output. See the installation section below for details.
- Can be installed globally across the entire server, selectively on individual accounts, or specifically to certain directories, filetypes, remote hosts, etc.
- Several optional meta tags can be added to pages. These override the global settings which are defined in the application and allow one to tweak the highlighting behaviour in a particular document:
- <META NAME="highlighter_on" VALUE=1>
- Enable (1) or disable (0) the highlighter.
- <META NAME="highlighter_jump" VALUE=0>
- Enable (1) or disable (0) the jump-to-first-match feature.
- <META NAME="highlighter_starttag" VALUE="<BLINK>">
- Use a custom highlighting tag. Useful on pages with different colour schemes.
- <META NAME="highlighter_endtag" VALUE="</BLINK>">
- Custom close tag for highlights.
- Non-English HTML character entities such as é (é) aren't supported. Searches containing them won't be highlighted.
- Words which are broken up with HTML tags inside them (like this) don't get highlighted when one searches for the entire word.
- No highlighting is displayed on pages which use frames. This is because the referer information doesn't make it past the frameset page to the frame content pages.
- If the page uses server-side includes, and an include performs an internal redirect (usually this is due to sloppy HTML coding) the order of the includes may be rearranged. This is a known bug in Apache (bug 17629) and looks like it will be fixed soon.
- Make sure that your copy of Apache is version 2.0.48 or later and has mod_ext_filter installed.
- Add the following to your Apache config.
SetEnvIf Referer "[?&]q=." do_highlight # Google, AltaVista, MSN, AllTheWeb, etc.
SetEnvIf Referer "[?&]query=." do_highlight # Lycos, AOL, HotBot, Netscape, etc.
ExtFilterDefine highlighter mode=output enableenv=do_highlight intype=text/html \
- Download highlighter.py and place it in the location specified above.
Problems installing or want something special? Read the advanced installation guide.
An entirely different strategy for providing search highlighting is to do
Another method is to use a custom Apache module. Adorn Software wrote one called
mod_suru which is pretty much identical
to my version, except that it costs money (mine is free) and only works on Apache 1.3.x
(mine only works for Apache 2.x).
Last modified: 7 August 2003