skip to Main Content

I am trying to change the PHP version by adding a handler to the .htaccess file in the root directory of the domain but it’s not working, The server is throwing a 403 Forbidden Error.
However, changing from the Cpanel PHP Selector option worked fine. But I don’t want to change the PHP version Globally on my server because some of my apps hosted on the server are using an older version of PHP which is 7.4.

Here is the handler I am using for PHP 8.1 on .htaccess

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php81” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php81 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

Please let me know What I am doing wrong?

2

Answers


  1. The 403 Forbidden error occurs primarily due to your wrong handler code.

    Try this one and it should work fine.

    AddHandler application/x-httpd-php81 .php 
    

    or this

    AddHandler application/x-httpd-alt-php81___lsphp .php
    

    Let me know in the comments if it works for you

    Login or Signup to reply.
  2. AddHandler application/x-httpd-ea-php81___lsphp .php .php8 .phtml .htm

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search