tsoHost Help Centre

Table of Contents

How to run PHP scripts with a different file extension

Updated Oct 31st, 2017 at 11:36 GMT

Sometimes you might want to execute PHP using a non-PHP file extension, for instance you might have an image handling script which you would like to be called imageHander.jpg instead of imageHandler.php.

To accomplish this, create a file called .htaccess in the same directory as the script. The filename must be exact and most text editors will allow you to save a file with this filename. If you already have a .htaccess file, you can edit it. Either way, add the line:


AddType application/x-httpd-php5 .jpg

This will allow .jpg files in that directory to execute as PHP.