|Wildcards and htaccess redirect|
In my htaccess file, I have a redirect for vistors looking for formmail, that redirects to a spider trap.
Redirect /cgi-bin/formmail.cgi [mysite.com...]
However, today, I had this in my logs:
GET /email@example.com&email=WantDis@aol.com&subject=blaa blaa
The redirect did not work for this, and it took about 2 dozen different requests by this clown (for variations: cgi, pl, different directories, before he finally got banned).
How can I get all requests that BEGIN with cgi-bin/formmail.cgi to automatically redirect to the trap, regardless of what appears after the word 'cgi'. I've tried using wildcards and have searched google and this forum but have had no success. Is this possible?
There is a bigger problem here: With the Redirect directive, you are using an external redirect - one that requires the cooperation of the remote user-agent to work. Redirect sends a 302 server response back to the requesting user-agent, a response that says, "This /cgi-bin/formmail.pl page has moved temporarily; Please re-request it from [example.com...] ." It is up to the user-agent to re-request that URL. If it does not, then your script won't be activated.
If you can use mod_rewrite, you can redirect internally and "silently" to your trap script:
RewriteRule form.?mail /cgi-bin/trap.pl [NC,L]
Alternately, you could create formmail.pl as a (Unix) link, pointed to trap.pl. Or, you could rename trap.pl to formmail.pl.
Using any of these techniques, the unwelcome visitor will not have a choice about activating your trap script, but with Redirect, he does.
Thanks for your response.
Unfortunately, Mod Rewrite is turned off on my server, so my only choices are the last 2 you suggested. It is no big deal for me to rename trap.pl to formmail.pl, by a Unix link, do you mean a full path link, i.e. /home/myhost/public_html/trap.pl -- perhaps this would be better as I suppose I could set up seperate links for the variations, such as formmail.cgi, formmail.pl, /formmail/formmail.cgi, etc, to catch these morons on the first attempt.
Would you be able to give me the contents I should write into the formmail.pl file to get it to redirect. I'm trying to find help on the web with no luck?
Hi again Jim,
I simply made copies of trap.pl and renamed them formmail.cgi and formmail.pl. But if you get a chance, I would be interested to know how I could have simply put links to one copy of trap.pl in these files and have it work.
A Unix link is equivalent to a Windows local shortcut. It is a pseudo-file that simply points to another file on the machine. It is not an html hyperlink. Therefore, what I was proposing is that you create a formmail.pl "file" defined as a Unix link, which simply points to trap.pl. In this case the formmail link "file" would have no contents - it would simply serve as an alias name for the real file it points to, much like the "shortcuts" on a Windows desktop point to files elsewhere on your hard drive.
If your ftp utility doesn't give you access to all Unix shell commands, you may have to telnet into your server to set this up. Or, if your hosting company is more helpful than usual, perhaps they would do this for you. If so, get them to set up as many "versions" of the link name as you might reasonably want or need, i.e. formmail.pl, formmail.cgi, guestbook.pl, etc. - all pointed to trap.pl.
Take a look at the Unix manual, and look for man page: link. Here is a summary version: [campuscgi.princeton.edu...]
Alternately, you could create your own formmail.pl file, and #include trap.pl within it. There are two goals; One is to only run one copy of trap.pl for efficiency purposes, and the other is to have only one trap.pl program so it is easy to modify and maintain. You could try something like the following in formmail.pl (I have not tested this):
The Unix link approach would be much more efficient, though. Also, if you use this #include approach, I recommend that you use the modified version [webmasterworld.com] of the trap.pl script that uses the flock file-locking mechanism in order to prevent interference between multiple copies of trap.pl running at the same time.