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.


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

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

This line uses the default shell version of PHP.

Additionally, using this directive in a FastCGI environment forces all PHP code in the specified extensions to run using CGI regardless of what option you choose in the panel.

AddHandler php5-cgi .test

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?