Forum Moderators: phranque
I have a Website that uses CGIEmail 1.6, which uses text templates to send replies to the recipients. The CGIemail Perl script is above my web-root in a cgi-bin directory that I cannot access by my FTP client, but the html forms and template files reside in my web-root, which I can access. The web host has configured their .htaccess files so that calls to cgi-bins are sent to the correct website, but above the visible root, and they then read the template files in each client's root directory and email the form results to us.
I want to conceal the destination script and template names from prying eyes, so in my comments form I want to change the POST destination from:
action="/cgi-bin/cgiemail/template.txt"
to
action="/c/r/1"
I want POSTs to /c/r/1 to go to the actual script and template locations. Is this the correct syntax to do what I want?
RedirectMatch /c/r/1 ht*p//w*w.mydomain.tld/cgi-bin/cgiemail/mytemplate.txt The owner of the website doesn't like me experimenting with scripts that might cause server errors and lock out any potential business, so I need to develop correct code offline.
Wiz
RedirectMatch uses regular expressions, so that pattern should probably be anchored, and special characters escaped.
If you use Redirect<anything>, you're going to create an external redirect, therefore requiring the client to re-request (re-post) the form to the 'real' URL.
I'd suggest you use mod_rewrite to create a server-internal URL rewrite only.
This may not be possible, either though -- since you'll need to know the actual local filepath to the script.
Jim
So, with that in mind, what needs to be escaped in these statements:
RedirectMatch ^/c/r/1$ http//www.mydomain.tld/cgi-bin/cgiemail/mytemplate.txt? W
However, if you use an external redirect, you are, in effect, handing the browser the correct address -- so I'm not sure there's any advantage to this exercise at all.
I've got the exact same setup on one of my hosts, and concluded there wasn't much I could do except block obviously-external referrers to the form. :(
Jim
Is this the correct syntax for an internal Rewrite to protect against hacked forms being submitted to our email script?
RewriteCond %{REQUEST_URI} /cgi\-bin/cgiemail/.? [NC]
RewriteCond %{HTTP_REFERER}!^http://www\.ourdomain\.com/(register¦contact¦reports)\.htm$
RewriteRule .* - [F]
Thanx, Wiz
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://www\.ourdomain\.com/(register¦contact¦reports)\.htm$
RewriteRule ^cgi-bin/cgiemail/ - [F]
If that is the case, then protect your forms:
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://www\.ourdomain\.com
RewriteRule ^(register¦contact¦reports)\.htm$ - [F]