Why is my website’s PHP code displaying directly on the page?

PHP code loading directly onto your site page rather than executing usually indicates an issue with the PHP version being defined on your site. Either it’s a broken definition, or the version being loaded isn’t using the correct path. When this happens, it’s best to check your site’s .htaccess files to see if you can isolate the cause.

A PHP version definition on our system should look like this by default:

#+PHPVersion

#=“php74”

AddHandler x-httpd-php74 .php

#-PHPVersion

The core line is the one starting with ‘AddHandler’. If your rule looks different to the above (beyond the version number) then it’s best to remove the rule and use the PHP Version tool in your site’s package to manually set this, or copy the above code and add it to your .htaccess to replace it.

Sites migrated from cPanel often have a rule similar to this:

# php—BEGIN cPanel-generated handler, do not edit

# Set the “ea-php56” package as the default “PHP” programming language.

 

AddHandler application/x-httpd-ea-php56 .php .php5 .phtml

# php—END cPanel-generated handler, do not edit

 

This isn’t a definition that would work on our system, so it would be worth removing it entirely. Once done, the site should then begin parsing the PHP code correctly and loading as normal.

  • 57 Utilisateurs l'ont trouvée utile
Cette réponse était-elle pertinente?

Articles connexes

Can you update the version of cURL on your webservers?

Occasionally, applications in your webspace may run checks to help ensure your website is secure....

Can I enable GZIP Web Server Compression?

Gzip is a great of compressing files for faster network transfers - helping them load faster, so...

Is Node.JS supported on the RabHost shared hosting platform?

Node.JS isn't currently supported on the shared hosting platform. If you need to use Node.JS,...

Why is my website not able to send email?

A common reason for this relates to the address not matching your site domain. To help improve...

What do I do if I believe a site is in breach of RabHost policies?

RabHost impose a strict Acceptable Use Policy and Terms of Service which customers must...