search

Home  >  Q&A  >  body text

The solution to the invalid solution of changing PHP version in .htaccess file

<p>I'm trying to change the PHP version by adding a handler in the .htaccess file at the root of the domain, but it doesn't work, the server throws a 403 Forbidden error. However, changing the PHP selector options via Cpanel works. But I don't want to change the PHP version globally on the server because some of my applications hosted on the server are using an older PHP version, which is 7.4. </p> <p>This is the handler I use in .htaccess for PHP 8.1: </p> <pre class="brush:php;toolbar:false;"># 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</pre> <p>Please tell me what I did wrong? </p>
P粉315680565P粉315680565455 days ago664

reply all(2)I'll reply

  • P粉761718546

    P粉7617185462023-08-26 12:57:39

    AddHandler application/x-httpd-ea-php81___lsphp .php .php8 .phtml .htm Please keep the html code and no need to add new content

    reply
    0
  • P粉300541798

    P粉3005417982023-08-26 10:24:01

    403 Forbidden errors are mainly caused by your error handler code.

    Try using the following code, it should work fine.

    AddHandler application/x-httpd-php81 .php

    Or use the following code

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

    If this is useful to you, please let me know in the comments.

    reply
    0
  • Cancelreply