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 –
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.
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 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
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!
When i did this on mywebsite all pages goes to download and i don`t have more how to navigate, now i go to cpanel and change the .htaccess to normaly sad day =(
Exact same experience as Juliano. My site is still functioning but when I try to log into the dashboard the link is changing to downloading the pages. Changed my .htaccess file back to it’s original state, but it’s still broken. :(
working like a charm :) very thankful