Trying to get a client's site up. The HTML files keep downloading rather than executing.

I've done a MIME check and the files appear to be text/html. I recreated the database admin, password and made sure that there was a connection between the script and the MySQL database. Permissions seem to be fine and the index.html is executable, permissions 755. Not sure where to turn next.

  • 2
    "I recreated the database admin..." - have you tried this without any "database" and a simple test.html file? By "download", presumably you mean you are prompted with a "Save As..." dialog? "index.html is executable, permissions 755" - "index.html" should not be executable and neither should it be 0755 - those are the permissions you would perhaps expect for an internal directory. – MrWhite Feb 23 '14 at 0:11
  • Can you tell us the procedure you did when doing the MIME check? I suspect your checking the config file in a text viewer when that's fine but it doesn't necessary mean that the config is being read. Have you done a PHP Info check? – Simon Hayter Feb 23 '14 at 12:04

When a web browser offers to download a file rather than open it, it is generally because the headers are incorrect. It sounds like you already checked the "Content-Type" header, but you also need to check the "Content-Disposition" header.

An easy way to check the headers on your page is to use the command line tool curl:

curl -s --head 'http://example.com/'

The "Content-Type" header should start with "text/html". There should be no "Content-Disposition" header. If you see something like this, you will need to configure your server to remove it:

Content-Disposition: attachment; filename="file.html"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.