• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

PHP and index.html and 405 error

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    PHP and index.html and 405 error

    Fourscore and ten years ago a friendly web designer made me a static html website(they were all the rage back then). I've added a feedback form (feedback.html) to it, which does this
    Code:
    <FORM NAME=FEEDBACK ACTION="process-feedback.php" METHOD=POST>
    -process-feedback.php being a script that looks at the input controls' values, puts them in an email, and sends it to me.

    When I click the 'submit' button on feedback.html, I get an error:

    405 method not allowed: The requested method POST is not allowed for the URL /process-feedback.php

    The wise armchair web developers on ExpertSexchange and the like all blithely say "Delete the index.html from the root folder, and it will work". And they are quite right - it does, beautifully. But I DON'T WANT to delete index.html because it is pretty darn integral to the website.

    Is there some kind of "third way" where I can get my post to work, without ripping the guts out of the nice linked-together html site, e.g. tell PHP to ignore index.html?

    The web server is a 3rd party hosted one, running Apache. So I'm not allowed to reconfigure the server, but I am allowed to put config files and stuff within the folders of my website. Apparently there's something called .htaccess files - can they rescue me?

    This is my first day of contact with PHP or Apache (& ideally my last) so I promise not to laugh at any suggestions. Oh and don't worry about potential knock-on effects to other php scripts, because I promise there aren't any.
    Last edited by thunderlizard; 8 March 2008, 11:14.

    #2
    Now hear's an answer from a Mechanical Engineer! Make index.html into index.php

    OK, I'm not a web author!
    Public Service Posting by the BBC - Bloggs Bulls**t Corp.
    Officially CUK certified - Thick as f**k.

    Comment


      #3
      Sounds like an Apache configuration error to me. I'm assuming apache 1.3 (I think Apache 2 allows you to post .html files by default).

      create a file called .htaccess in the folder your feedback.html is in and populate it with the following:
      Code:
      AddHandler cgi-script .html
      That should make apache parse html files as cgi files hence allowing the post.

      Comment


        #4
        ooh - I'll give that a go!

        Comment


          #5




          oh, and...


          well I did it and it worked.

          Actually it was a bit odd. I did exactly as you suggested and got a "not authorised" error on all the pages in my \feedback\ folder. I also noticed that the .htaccess file wasn't visible in my FTP view, as if it had been immediately eaten after upload. So in an attempt to isolate variables, I deleted the \feedback\ folder, and re-filled it again, but without the .htaccess. And it has worked nicely ever since!

          I'd only just upgraded my hosting to allow PHP, so there's a small possibility that it hadn't been 100% enabled until some point this week. But Ardesco you clearly know your stuff, and your web hosting service might find itself with an extra customer when renewal time comes around!

          Comment


            #6

            Comment


              #7
              Well done, comments made about web hosting duly noted.
              Public Service Posting by the BBC - Bloggs Bulls**t Corp.
              Officially CUK certified - Thick as f**k.

              Comment


                #8
                Originally posted by Fred Bloggs View Post
                Now hear's an answer from a Mechanical Engineer! Make index.html into index.php

                OK, I'm not a web author!
                This will kill your search engine rankings if you have any
                "Is someone you don't like allowed to say something you don't like? If that is the case then we have free speech."- Elon Musk

                Comment


                  #9
                  I migrated a website from static html website to a php based CMS website (phpnuke based). The website has been in the top 2 to 5 on Google for about 7 years. The change from index.htm to index.php made no difference what so ever to Google.
                  Public Service Posting by the BBC - Bloggs Bulls**t Corp.
                  Officially CUK certified - Thick as f**k.

                  Comment


                    #10
                    Originally posted by Fred Bloggs View Post
                    I migrated a website from static html website to a php based CMS website (phpnuke based). The website has been in the top 2 to 5 on Google for about 7 years. The change from index.htm to index.php made no difference what so ever to Google.
                    You changed it when?

                    I recently was going to change all my pages from .html to .php and was told that renaming them would make the SE's see them as new files?

                    http://www.warriorforum.com/forum/to...OPIC_ID=220411

                    Are you saying this is untrue?
                    "Is someone you don't like allowed to say something you don't like? If that is the case then we have free speech."- Elon Musk

                    Comment

                    Working...
                    X