Tsohost Knowledge Base

How to run PHP scripts with a different file extension

Modified Monday 18th August, 2014 at 10:53

Was this helpful?

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:

Code:

AddType application/x-httpd-php5 .jpg

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


PHPscriptsfileextension

Still can't find what you're looking for?

Not a problem - our 24/7 customer support team are super friendly and here to help answer all your questions. There's no need to wait, click below to start a Live Chat.

Start Live Chat

Still can't find what you're looking for?

Not a problem - our 24/7 customer support team are super friendly and here to help answer all your questions. Don't delay, click below to find out how you can get in touch.

Get in Touch