Forum Moderators: phranque

Message Too Old, No Replies

htaccess conflicts with cgi formmail.pl

         

Lorel

11:08 pm on May 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have a contact form set up using formmail.pl and it won't work unless I take out the htaccess file which has the usual canonical fix. I'm told both seem to be set up correctly but htaccess apparently needs an extension so it doesn't try to go into the cgi-bin and bring up formmail.

When I test the contact form it reverts to the home page instead of a thankyou page. It's getting waylaid in the cgi bin and never gets to the thankyou page.

Can someone tell me if there is something wrong with this htaccess or how to fix it so the contact form will work?

AddHandler server-parsed .html
ErrorDocument 404 /missing.html

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com [R=301,L]

Here is the relevant part of the form:

<FORM METHOD=POST ACTION="http://example.com/cgi-bin/formmail/FormMail.pl">
<input type="hidden" name="recipient" value="info@example.com">
<input type=hidden name="required" value="Name,Email,Comments">
<input type="hidden" name="return_html" value="http://www.example.com/thankyou.html">

jdMorgan

12:55 am on May 11, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First, make all of your hostname references consistent and change the rewriterule to preserve the requested URL-path...

RewriteEngine on
#
# Externally redirect requests for non-blank non-canonical hostnames
# to the canonical hostname, preserving the requested URL-path
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.co[b]m/$1[/b] [R=301,L]

<!-- Since the canonicalization rule in .htaccess forces "www.example.com"
all links, included-object references, and POSTs should be to "www" only -->
<FORM METHOD=POST ACTION="http://[b]www.[/b]example.com/cgi-bin/formmail/FormMail.pl">
<input type="hidden" name="recipient" value="info@example.com">
<input type=hidden name="required" value="Name,Email,Comments">
<input type="hidden" name="return_html" value="http://[b]www.[/b]example.com/thankyou.html">

Jim

Lorel

1:54 am on May 11, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks Jim, that worked