AddType in htaccess causes page to download

前端 未结 9 1967
走了就别回头了
走了就别回头了 2020-12-16 18:34

I have read about 10 questions like this, but there seems to be no answer to this simple question.

What could cause .htm files to be downloading instead of executed

9条回答
  •  一整个雨季
    2020-12-16 18:53

    I'm sharing my own experience with this super frustrating issue. My host got taken over by another hosting provider and they changed technologies. One of the changes allowed me to edit my own PHP version at will, but absolutely none of them (from the lowest 5.4 to the highest 7.2) worked properly. I was using a global .htaccess across all my domains (placed in the root) and had my AddType-s and AddHangler-s at the beginning of the file. Little that I knew - when I had been changing PHP versions, the little bugger wrote the correct string defining the proper name of my PHP version at the very end of that .htaccess file. When I defined the types at the beginning of the file, I was using the wrong handle and that skipped the bottom declaration altogether, Apache didn't recognize the technology and decided to spew out a direct download.

    So watch for custom PHP handle definitions on your hosting providers.

    What worked for me in the end was:

    
      AddType application/x-httpd-ea-php72___lsphp .php .php7 .phtml .htm .html
    
    

    Note the "___lsphp" appended at the end of the standard "x-httpd-ea-php72" handle...

    God, that ate me up so much...

提交回复
热议问题