Forum Moderators: phranque

Message Too Old, No Replies

.htaccess interfering with form

a recently added .htaccess to redirect has broken the formail.pl on our sit

         

vee3

10:07 pm on Jul 15, 2008 (gmt 0)

10+ Year Member



I recently added a .htaccess file to redirect other web addresses we own to our site, but it has broken all the forms on the site so I have had to remove it. Can anyone suggest a solution?

The .htaccess currently reads:


Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.co.nz [nc,OR]
rewritecond %{http_host} ^www.example.co.nz [nc,OR]
rewritecond %{http_host} ^example-international.com [nc]
rewriterule ^(.*)$ http://www.example-international.com/$1 [r=301,nc]

Thanks

[edited by: jdMorgan at 12:04 am (utc) on July 16, 2008]
[edit reason] Please use example.co [/edit]

jdMorgan

12:11 am on Jul 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We'll need more information on what the exact problem is.

How did you test? What were the results? How did these results differ from your expectations? What is the contents of your server error log when the error occurs?

Look at the form itself, and make sure the address it posts to is your canonical domain.

Look at the script that receives the post, and be sure that it does not redirect to the "wrong" domain.

We need a good, detailed technical description of the problem in order to suggest a solution. However, since all the above rewriterule does is to redirect alternate domains to your canonical domain, you are probably looking for a problem in the code that causes a redirect *back* to an incorrect domain, possibly setting up an 'infinite' redirection loop.

BTW, you can shorten/speed up the code a bit. I'd suggest:


Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^(www\.)?example\.co\.nz [NC,OR]
RewriteCond %{HTTP_HOST} ^example-international\.com [NC]
RewriteRule (.*) http://www.example-international.com/$1 [R=301,L]

Shorter, and with several other minor tweaks. No change to function, except for "[L]" flag.

Jim

vee3

2:19 am on Jul 16, 2008 (gmt 0)

10+ Year Member



Jim

Thanks very much for your help, I will see if I can track the error down from your suggestions. The error message that is coming up is:

The HTML form fails to specify the POST method, so it would not be correct for this script to take any action in response to your request.

If you are attempting to configure this form to run with FormMail, you need to set the request method to POST in the opening form tag, like this: <form action="/cgi-bin/FormMail.pl" method="post">

Cheers

Charles

jdMorgan

4:21 am on Jul 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is possible that some HTTP/1.0 clients may change the POST to a GET upon receiving a 301-redirect from your server. But true HTTP/1.0 clients are very rare these days. They're obsolete, since they cannot access name-based servers, and name-based server now make up a large portion of the Web -- possibly the majority. Modern HTTP/1.1 clients should not have this bug.

However, you could easily check the client-server interaction on POST by using either a known-reliable* on-line server headers checker, or by using something like the "Live HTTP Headers" add-on for Mozilla/Firefox browsers. Enable the add-on, then try submitting your form; It will report all of the headers exchanged between the browser and the server.

* Some on-line server headers checkers do not report all phases of the client-server interaction. Notably, some only report the initial client request and the final server response, and do not show intervening redirection transactions.

Be sure that the form is posting to the canonical domain, so that the redirect is not invoked. If it's not, then examine the "action" tag in the form, and correct it to POST to the proper domain.

If for some reason you cannot correct the form, there is a possible work-around. Let us know.

Jim