Bluehost Web Hosting Help

How To Add Handlers To Change PHP Version - PHP Version Setup

Overview

This article will explain how to add a PHP handler to your .htaccess files. This is useful if you want to customize the version of PHP that runs your PHP files by directly editing your .htaccess file. If you do not wish to edit the .htaccess file you can use the cPanel to change your php version as explained in PHP Config.



Adding the Handler to the.htaccess File

The PHP handler is written into the .htaccess file. The .htaccess file is a hidden file that is read by the web server. The web server follows any instructions contained within the file. There are many ways to access this file. For the purposes of this article, we will explain accessing it through the File Manager on the cPanel of your hosting account.

Rock

  1. Log in to your Bluehost.com  account.
  2. Click the Advanced tab from the side navigation menu to the left.
  3. Under the File section, click the File Manager icon.
  4. Look for the Settings button located towards the upper right corner of your screen.
  5. Click the Preferences, then toggle the radio button for "Show Hidden Files (dotfiles)."
  6. Click the Save button when finished.
  7. Locate the .htaccess file, right-click on it, and select edit.
  8. At the top of the file, insert the PHP handler for the version you would like to use. If there is a handler in the file already, it should be removed or replaced with your new handler.
  9. Click Save.

Legacy

  1. Open the File Manager located on the cPanel.
  2. Choose Web Root, select Show Hidden Files, and click the submit button on the directory selection popup.
  3. In the table of files, you should see a file named .htaccess, right-click on it and select the code edit.
  4. You may get a popup asking about encoding. If so, click the edit button.
  5. At the top of the file, insert the PHP handler for the version you would like to use. If there is a handler in the file already, it should be removed or replaced with your new handler.

    Note: See the Available PHP Handlers section for handlers on each PHP version available. You can copy and paste these directly into the file.

  6. Click Save.

Once you have saved the file, you can close it. Your account will then use the PHP version you selected.

Available PHP Handlers

Please note: We will be updating to PHP version 8.0 in batches beginning in 2022. Keep an eye out for communications on when your account will be updated and what changes, if any, you will need to make. For more information on updating content for PHP compatibility, read our guide on What to do if your Site Does not Work with Newer Versions of PHP. To learn more about what is changing with PHP 8.0, please see PHP.net's release notes.

The following handlers can be copied and pasted directly into your .htaccess file:

PHP Standard PHP (Default)

All accounts use Standard PHP by default. You can install the default php.ini file to your public_html folder using the PHP Config option inside your cPanel. You can make any changes or modifications to that file and take a guide over the master file. The Standard PHP on the cPanel will need to copy the modified php.ini file into all subdirectories, including PHP files, to use the custom PHP settings.

            # Use PHP(7.3|7.4|8.0|8.1) as default
            AddHandler application/x-httpd-php(73|74|80|81) .php

PHP Single php.ini

The Single php.ini will help you avoid copying the same php.ini file to each directory containing php files. This option changes the PHP handler defined in ~/public_html/.htaccess to indicate that all subfolders use the same php.ini found in public_html/.

            # Use PHP(7.3|7.4|8.0|8.1) Single php.ini as default
            AddHandler application/x-httpd-php(73|74|80|74)s .php

Important Note: The .htaccess PHP handler is looping through all subdirectories unless a subdirectory has a .htaccess file and defines a PHP handler.

PHP FastCGI

The FastCGI for PHP makes all your PHP applications tenacious and uses only one php.ini file in the public_html directory. Also, there is no per-request startup and initialization indirect cost. 
This PHP makes possible the development of applications that would otherwise be ineffective within the CGI paradigm (e.g., a huge PHP script or an application that requires a connection to one or more databases). Using the PHP FastCGI option makes all your PHP applications run through mod_fcgid instead of mod_suphp.

            # Use PHP(73|74|80|81)CGI as default
            AddHandler fcgid(73|74|80|81)-script .php
Knowledgebase Article 405,622 views bookmark tags: htaccess php


Was this resource helpful?

Did this resolve your issue?


Please add any other comments or suggestions about this content:





Recommended Help Content

Apache Handlers

What are Apache Handlers? How do I setup customized Apache Handlers?

How To Change Your PHP Version - PHP Config Guide

How to change your PHP version in your hosting account

Easy Apache

This article will explain how to use Easy Apache to recompile Apache. This is useful if you want to change the version of PHP or change other PHP and Apache settings.

Related Help Content

Change Your PHP Version - Dedicated and VPS Hosting

Changing PHP versions, load custom Apache mods, and other Apache/PHP customizations

Microsoft 365 - How to Access Microsoft Outlook Email

This article will explain how to access Microsoft Outlook online or directly from your Desktop.

Intro to FTP

There are many ways that you can transfer files and folder to and from your hosting account. We highly recommend using an FTP (File Transfer Protocol) program to quickly upload and download files. We

Redirects that do not work due to PHP variables

The redirection of www.yourdomain.com/default.html or index.html to http://www.yourdomain.com/index.php?act=whatever redirects it to http://www.yourdomain.com/index.php%3fact=whatever In other words,

How To Configure The PHP Environment With PHP ini

How do I change the PHP environment for my site with php.ini?

500 Internal Server Error when trying to install something with MOJO Marketplace

500 Internal Server Error when installing via the MOJO Marketplace installer.

Executing PHP code within an HTML document

Executing php code within a HTML document

How To Edit An .htaccess File - Edit htaccess file in cPanel's File Manager

Explains how to edit the .htaccess