PHP Code Is Showing on Joomla Website

One of our clients called us today and said: “Help! My Joomla website is not working! It is displaying code instead of my content!”. We checked his website and true enough, it was indeed displaying PHP code instead of displaying actual content.

We’ve seen this problem before and we know that there are several reasons that can make it happen:

  • The website is moved to another host, but that other host does not have PHP installed.
  • PHP is installed on the server hosting the website, but Apache is not instructed to load the PHP module through the LoadModule directive in its httpd.conf file.

  • PHP is installed and the PHP module is successfully loaded, but the PHP handler (that tells Apache to associate .php files with the PHP application) does not exist. In other words, the following line is missing from the httpd.conf file:

    AddType application/x-httpd-php .php

  • The .htaccess file has explicit instructions to override default server settings and not to execute php files but to serve them as text instead. This happens when the following 2 lines are present in the .htaccess file:

    php_flag engine off
    AddType text/plain php

    The first line instructs the server not to process PHP files, and the second line tells the server to treat PHP files as plain text and display their content (as is) in the browser.

  • Malicious code is inserted into the index.php file. That malicious code simply spits (echoes) the PHP code in that file. This kind of hack is very deceptive, because it looks like as if the PHP parser is not working, while it really is, and usually (in this situation) the last thing that the developer will consider looking at is the index.php file.

For this client, the issue was that he moved his website from a Linux server to a Windows server that didn’t have PHP installed. It took us a few minutes to discover the issue.

If your PHP code is being displayed (instead of being processed) in your Joomla website, then we suggest you call your hosting company and ask them to check the issue for you. If they still can’t help you, then just contact us – we’d be happy to fix the problem for a very reasonable fee!

One Response to “PHP Code Is Showing on Joomla Website”
  1. Comment by Patrick — January 21, 2015 @ 3:05 am

    Nice, my .htaccess file already had a PHP handler but it was the wrong one, thank you for this great post!

Leave a comment