AddType in htaccess causes either download or HTTP ERROR 500

10,343

Solution 1

For Godaddy, my solution was, after updating the php to add the following line (Taking the old php declaration out):

AddHandler application/x-httpd-alt-php74___lsphp .php .html .htm

It really just required the explicit declaring of the page type.

Solution 2

It seems that there are PHP version conflicts on your server, the easiest way to solve this is to just update the PHP version on your server.

Take a Backup before doing anything!

Go to the terminal of your server and type this: php -v

This should give you the PHP version installed on your server, now make sure that your .htaccess handlers match the installed PHP version.

So for example, if you have this as the handler: AddHandler application/x-httpd-ea-php71 .php your PHP version should be 7.1

If you change the .htaccess handlers without updating your PHP version, you will get a conflict.

This is Bluehost's official guide https://my.bluehost.com/hosting/help/htaccess-php-handlers

I hope this helps!

Share:
10,343
Jelly Jarkskin
Author by

Jelly Jarkskin

Updated on August 24, 2022

Comments

  • Jelly Jarkskin
    Jelly Jarkskin over 1 year

    Currently using "AddHandler application/x-httpd-ea-php56 .php" in my htaccess file in the root of the domain since that is the only thing that works.

    If I try to switch to php7, the page either tries to download or it gets the HTTP ERROR 500.

    The following downloads the page:

    AddHandler application/x-httpd-ea-php7 .php
    

    The following gives me 500 error:

    AddHandler application/x-httpd-ea-php71 .php
    

    Downloads the page:

    AddHandler x-httpd-php7 .php
    

    500 error:

    <IfModule mime_module>
      AddType application/x-httpd-ea-php72 .php .php7 .phtml .htm .html
    </IfModule>
    

    500 error:

    <IfModule mime_module>
      AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
    </IfModule>
    

    downloads the page:

    AddHandler application/x-httpd-php7 .php .html .htm .phtml .shtml
    

    etc

    In subdirectories, I can use the following just fine:

    <IfModule mime_module>
      AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
    </IfModule>
    

    Try to use that in the root .htaccess file...poof no cookie.

    If I add AddHandler application/x-httpd-ea-php56 .php back in, it works fine again.

    I have also tried other some other methods I found searching around. Has anyone else had this issue? The host is Bluehost.

    The only other things semi-related that I have in the root htaccess file is the following, but I have tried removing it as well with no change to the results:

    AddHandler server-parsed .html
    AddHandler server-parsed .htm
    
    • Dave
      Dave over 4 years
      What version of Apache are you using?
    • Dave
      Dave over 4 years
      The correct statement, within the <IfModule mime_module> section is AddType application/x-httpd-php .php. And of course make sure you have loaded the PHP7 module LoadModule php7_module "/pathto/PHP/php7apache2_4.dll"
    • Jelly Jarkskin
      Jelly Jarkskin over 4 years
      Apache Version 2.4.39 Trying to make the suggested changes led to the same. <IfModule mime_module> LoadModule php7_module "/pathto/PHP/php7apache2_4.dll" AddHandler application/x-httpd-ea-php7 .php .php7 .phtml </IfModule> or <IfModule mime_module> LoadModule php7_module "/pathto/PHP/php7apache2_4.dll" AddType application/x-httpd-php7 .php </IfModule> led to even worse of an error.
    • Jelly Jarkskin
      Jelly Jarkskin over 4 years
      <IfModule mime_module> AddType application/x-httpd-php .php </IfModule> led to 500 error (even if you add 7 to the x-httpd-php)
    • Dave
      Dave over 4 years
      I'm assuming the LoadModule line you used actually had the path to where you have PHP installed.
    • Jelly Jarkskin
      Jelly Jarkskin over 4 years
      To the best of my knowledge, yes. I believe the path to be /usr/php/70/ but I can't see that sadly since it's a shared account and I can't back up that far. Stuck in /home/username as the closest to root directory I can get.
    • Dave
      Dave over 4 years
      That is information your hosting provider should provide and have available. You have to get that correct or nothing is going to work.
  • Jelly Jarkskin
    Jelly Jarkskin over 4 years
    Sadly, I don't have access to doing that this round. It's a shared account.
  • genzdev
    genzdev over 4 years
    I think you can still update PHP version even if it is a shared account, if you have Cpanel installed, do this: my.bluehost.com/hosting/help/php-version-selection-php-confi‌​g
  • Jelly Jarkskin
    Jelly Jarkskin over 4 years
    I know I have the method, but I am reluctant to click on it. MultiPHP Manager does show 5.6 for the main directory and everything else shows 7.3, however, if changing it to 7.x from htaccess causes it to error like it has, I have wondered if the same thing would happen from MultiPHP Manager. If so, it warns that I wouldn't be able to go back as I'd be stuck with the options of 7.0 - 7.3. So if it does error, then I would be stuck and the site would be offline for god knows how long until it is fixed.
  • Thevin Malaka.
    Thevin Malaka. almost 2 years
    This one works for me.