Introduction
The Apache Handlers feature in cPanel allows you to control how the Apache web server processes files with specific extensions or MIME types. This is useful if you want certain file types to be handled by a specific program, script interpreter, or engine — such as forcing .cgi
or .py
files to run using a specific handler.
This article explains what Apache Handlers are and how to add or manage them in cPanel.
What Is an Apache Handler?
A handler tells the Apache server how to process a file based on its extension. For example:
File Extension | Handler |
---|---|
.cgi |
cgi-script (executes as a script) |
.php |
application/x-httpd-php (interpreted by PHP engine) |
By using Apache Handlers, you can override default behavior or assign new actions to custom file extensions.
Why Use Apache Handlers?
-
Enable scripting for custom file extensions (e.g., make
.app
files run as PHP) -
Force certain file types to be processed differently (e.g., treat
.txt
as HTML) -
Support compatibility with older scripts or custom software
-
Enhance flexibility for advanced development needs
How to Access Apache Handlers in cPanel
-
Log in to your cPanel account
-
Scroll down to the Advanced section
-
Click on Apache Handlers
Adding a Custom Apache Handler
-
Under Create an Apache Handler, enter:
-
Handler: The processor (e.g.,
application/x-httpd-php
) -
Extension(s): File extension(s) without the dot (e.g.,
app
,custom
)
-
-
Click Add
From now on, files with those extensions will be processed by the specified handler.
Example Use Case
Let’s say you want .custom
files to be executed as PHP scripts.
-
Handler:
application/x-httpd-php
-
Extension:
custom
Now, visiting example.com/script.custom
will execute it as a PHP file.
Managing Existing Handlers
-
Scroll down to the User-Defined Apache Handlers section
-
Click Delete to remove a custom handler if needed
System-defined handlers (default ones) can’t be removed from here.
Best Practices
-
Only modify Apache Handlers if you understand how file processing works
-
Be cautious: incorrect handlers can expose your files or break functionality
-
Custom handlers are ideal for legacy apps or experimental setups
-
Always test changes on non-production environments when possible
Conclusion
The Apache Handlers tool in cPanel gives you advanced control over how the server processes different file types. By creating custom handlers, you can enhance compatibility, support custom extensions, or modify how your scripts run — all without needing direct access to server configuration files.