At some point, you might need to change the PHP version of your WordPress website, especially if you’re running on an old version.

So, in this tutorial, I’ll show you how to do that using .htaccess, which is a configuration file for servers that run on the Apache software.

Change the PHP version of your WordPress site using .htaccess

Before proceeding, back up your .htaccess file or your entire website, just to be extra safe!

Also, if you’re doing this to permanently upgrade the PHP version of your WordPress website, find out if your web host, theme, and plugins support a higher version of PHP, such as 7+.

Step 1 – Access your site’s files

Here’s how to access and edit your WordPress website’s files.

The .htaccess file should normally be in your WordPress website’s root folder – public_html.

.htaccess via cPanel

.htaccess in cPanel

Step 2 – Edit the .htaccess file

Open the .htaccess file for editing.

If you’re in cPanel, right-click on it and select Edit or Code Edit.

edit .htaccess in cpanel

Editing .htaccess in cPanel

Step 3 – Add the code and save the file

I’ll give you several handlers to add, but you should stick to PHP 7+ (7.2 currently recommended) because it’s faster and more secure!

Add one of the below handlers right above the #BEGIN WordPress line in your .htaccess file.

change php version wordpress .htaccess

Change to PHP 7.3

AddHandler application/x-httpd-php73 .php

Change to PHP 7.2

AddHandler application/x-httpd-php72 .php

Change to PHP 7.1

AddHandler application/x-httpd-php71 .php

Change to PHP 7.0

AddHandler application/x-httpd-php70 .php

Change to PHP 5.6

AddHandler application/x-httpd-php56 .php

Change to PHP 5.5

AddHandler application/x-httpd-php55 .php

Related posts:

That’s a wrap

Hope you found the tutorial useful and managed to change the PHP version of your WordPress website using .htaccess!

Don’t forget to share the post to help out others!

You can quickly subscribe to my newsletter by using this link.

If you have any questions or thoughts, drop a comment or send a message via contact or Facebook page.

You can also hit the follow button on Twitter and subscribe to the YouTube channel.

My WordPress website or blog services are at your disposal!