Unfortunately, I can't give more than general help and learning tips. I'm only a casual user of mod_rewrite and don't have an experimental Apache server handy.
On one foot, mod_rewrite lets you use Perl compatible regular expressions to convert a part of a URL you don't like to one you do like. The phrase "Perl compatible" should be taken with a small grain of salt - usually it means some subset of full-blown Perl regexes. I've never really done much more than simple rewrites, so I don't really know how full the emulation is (perhaps some other monk does?).
The hardest part of mod_rewrite is learning its syntax for selecting URLs to be rewritten. In my experience, when mod_rewrite "doesn't work", it is usually a screw up with the selection process: thinking selection criteria are being or'd when they are really being and'd; regexes that don't do what you think they do; accidentally chaining together rules, and so on.
Basically, you define a set of rules for selecting a URL using a series of RewriteCond statements. Each of these has three parts: the word "RewriteCond", a variable representing the thing you want to match (e.g. %{REMOTE_HOST}), and a regex to compare to it. These are the equivalent of $servervar =~ /.../ expressions in Perl.
A series of these RewriteCond statements is normally and'd together but you can "or" them, by adding [OR] at the end of each RewriteCond statement. At the end of all of the RewriteCond statements, is a RewriteRule statement. This contains the URL transformation and has the format:
RewriteRule regex-matching-what-you-want-to-get-rid-of text-you-actually-want.
You can think of it as a fancy version of Perl substitution: s/regex-matching-what-you-want-to-get-rid-of/text-you-actually-want. So your redirection to MolSurfer might look something like this:
RewriteCond %{REMOTE_HOST} ^host1.* [OR]
RewriteCond %{REMOTE_HOST} ^host2.* [OR]
RewriteCond %{REMOTE_HOST} ^host3.*
RewriteRule regex replacement-for-regex [R,L]
The things in square brackets at the end are instructions to the server. [OR] was already discussed above. L means "the end". If it is missing, and there is another set of RewriteCond/RewriteRule statements after it, Apache chains them, just as if you had successive $foo =~ s/blah/blech/ statements in a Perl script. [NC] means ignore case. See the documentation for other codes.
The official documentation is very far from a tutorial, so here are some articles with examples. These should get you started. After reading them, you may want to go back to the mod_rewrite reference page and see if anything there starts making more sense.
You might also try searching the net for Apache forums - you are likely to get more detailed help there.
There is also a way you can insert a Perl script to do the URL conversion if you need to get a bit fancier with the conversion or use something like a lookup table stored in a database, but that is a lot more complex than you probabably need right now. If you are interested in it later on, scan the main mod_rewrite documentation page for the word "Perl". They have a short sample script.
Best, beth |