How to Change PHP Version for Current Directory – Godaddy – Linux Hosting

So, I recently had a special case where my client was using older version of php in his godaddy hosting and didn’t want to upgrade. But for the current project I needed to enable php 5.4. I couldn’t use godaddy control panel to change/upgrade php version because that would change the php version for whole account. So I needed to find a better solution that only allow to change php version for the current project folder and all folder beneath.

This might sound complicated but you need to add just a piece of code to your .htaccess file to do it.

This is how:

  1. Go to the root of your project folder.
  2. Download `.htaccess` file from root folder if there is any or just create a file on your computer.
  3. Add this piece of code `AddHandler x-httpd-php5-4 .php`
  4. Save the file.
  5. Upload it to your project folder.

And you are done 🙂







8 responses to “How to Change PHP Version for Current Directory – Godaddy – Linux Hosting”

  1. Jake Avatar

    Thank you! Saved my at least an hour 😀 Confirming that it works on current godaddy sites. Linux hosting.

  2. Wesley Phibbs Avatar

    Thanks, saved me as godaddy wouldn’t let me update from php5.3! This fixed worked for now.

  3. Marco Avatar

    I’ve tested this method and it’s not working anymore on GoDaddy shared hosting accounts. It’s ok on HostGator.

    Any suggestion is welcomed.

    Thank You

    1. sisir Avatar

      Was you able to fix it?

  4. Sri Lanka Web Design Avatar

    Thanks! It worked in 4G hosting package.

  5. Webstore Avatar

    Does not work on GoDaddy.

    1. sisir Avatar

      What hosting package do you have?

  6. Arvind Subrmanian Avatar

    tried to upgrade to php 5.6 for one folder using the htaccess file but it didnt worked.

    #added below line
    AddHandler x-httpd-php5-6 .php

Leave a Reply

Your email address will not be published. Required fields are marked *