http://qs321.pair.com?node_id=38291

moath has asked for the wisdom of the Perl Monks concerning the following question:

I've got a script that SHOULD accept input from a form using the POST method. However, I keep getting "Method Not Allowed" error. The error code is 405. Is this just a misconfiguration in Apache, or is there something wrong with my script. The script is a big large to post, but what can you tell from what I've said thus far?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: Method Not Allowed
by extremely (Priest) on Oct 25, 2000 at 11:51 UTC
    Sounds like Apache to me. It is a straight CGI I assume and not a mod_perl Registry script. I'd bet on a line like
    <Location />
      <Limit POST PUT DELETE>
      Deny all
      </Limit>
    </Location>
    in your config...
      In the case where certain methods are <Limit>ed, the message should be a stock "403 Forbidden", not a "405 Method not allowed".
Re: Method Not Allowed
by Fastolfe (Vicar) on Oct 25, 2000 at 20:13 UTC
    This sounds like your script is not in a directory recognized by your web server as a CGI directory (such as /cgi-bin/). If you're attempting to put Perl scripts anywhere in your document hierarchy, be certain your web server is set up to handle files of that extension as a CGI script. For example, with Apache, place this in the relevant <Directory> or <Location> blocks, or if you don't care to localize the effect, anywhere else will do:
    AddHandler cgi-script .pl
    The problem stems from the fact that your script may be being interpreted as a plain document, which cannot be POSTed to. You have to tell the server to interpret that file as a CGI script instead of a document, which involves placing it in a directory set up for CGI scripts, or telling the server that documents with that extension/MIME type should be treated as CGI scripts.
Re: Method Not Allowed
by AgentM (Curate) on Oct 25, 2000 at 20:22 UTC
    Take one step at a time- test a bland CGI like this:
    use CGI qw/:standard/; print '<html><head><body>hi';
    Then you're SURE to find out where the error is (since it's not in the bland CGI).
Re: Method Not Allowed
by Anonymous Monk on Apr 04, 2004 at 09:13 UTC
    The answer is simple, only it took me too long to find it. The problem is you reinstalled apache and this replaced the httpd.conf file. That file is now missing two important line for php: LoadModule php4_module Libexec/apache/libphp4.so AddModule mod_php4.c The solution is to reinstall php it will fix the httpd.conf file. This will solve the Method not allowed for POST

    Originally posted as a Categorized Answer.