Force other file extensions to load as PHP


This article explains how to force PHP to load a file that does not end with the extension .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
FcgidWrapper "/dh/cgi-system/php74.cgi" .test

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


If you want to use CGI (instead of FastCGI), add the following line to your .htaccess file:

This line forces all code to run using CGI. However, the PHP version of your site remains the same as the version of PHP you selected in the panel.

For example, if you select PHP 8.1 FastCGI in the panel, this line forces your site to use PHP 8.1 CGI.

AddHandler php5-cgi .test

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?