Change file extension handlers/languages (Linux)

Your Linux Web Hosting account lets you process files in different languages. File extensions determine your account's default behavior. For example, your account processes files ending in .html as static HTML, and your account's default PHP version processes files ending in .php.

With Apache handlers, you can update your .htaccess file to change your account's default file extension behavior, or you can add custom file extensions.

Refer to the following table for the default behavior of dynamic languages.

Extension Handler Version
.php x-httpd-php Default PHP version
.php5 x-httpd-php5-3 PHP 5.3
.pl, .rb,
.py, .cgi
cgi-script Language dependent
.fcgi, .fpy,
.fpl
fcgid-script Language dependent


Warning: Changing the default behavior of file extensions in your hosting account can yield unexpected results, possibly disabling installed software. This advanced feature is intended only for experienced users.

Some extensions require language-specific scripting preparation (for example, scripts for use via CGI or FastCGI), which is beyond the scope of this article.

Changing Default File Extensions

You can change your account's default file extension behavior by updating your .htaccess file with a handler.

For example, if your PHP version opens file extension .php, and you want to change it to PHP 5.3, add the following code to your hosting account's .htaccess file:

AddHandler x-httpd-php5-3 .php

Likewise, if you want FastCGI to process all files with extension .pl, add the following code to your hosting account's .htacess file:

AddHandler fcgid-script .pl


Creating Custom File Extensions

You can also create custom file extensions by updating your hosting account's .htaccess file with a handler.

For example, if you add the following code to your .htaccess file, PHP 5.3 can process the custom extension .mysite:

Options +ExecCGI
AddHandler x-httpd-php5-3 .mysite

Disabling FastCGI

You can disable FastCGI using this method by including the following in your .htaccess file:

Options +ExecCGI
addhandler x-httpd-php5-cgi .php

You cannot disable FastCGI with our cPanel shared hosting accounts (more info) or Web/Classic accounts using PHP versions 5.3 or later (more info).

Click here for more information about Apache handlers.