How do I force other file extensions to load as PHP?

To process files with PHP whose names don't end with ".php", you can use a directive in .htaccess.

For example, create a file named myfile.test with the following code:

echo ‘testing an extension using PHP’;

The extension .test doesn’t exist. But, you can force it to run as PHP by adding this code to your .htaccess file:

AddHandler fcgid-script .test
FCGIWrapper "/dh/cgi-system/php56.cgi" .test

If you load the file in a browser, it will now load as a normal PHP file.


In the above example, files with the extension .test are using PHP 5.6 with FastCGI.

If you do not want to change the version of PHP but want PHP to use CGI (instead of FastCGI), use this line in your .htaccess file:

AddHandler php5-cgi .test

If you want to use the default version of PHP and CGI, use the following:

AddHandler php-cgi .test

If you use either the ‘php5-cgi’ or ‘php-cgi’ directive in a FastCGI environment you'll force all PHP code in the specified extensions to be run using CGI regardless of what option you choose in the panel.

See also

Did this article answer your questions?

Article last updated .