Enable CGI, SSI with .htaccess
Web Hosting Articles »
A simple guide to .htaccess »
Enable CGI, SSI with .htaccess
As .htaccess is a powerful tool. It gives you option to change the way the webserver serves your files. On most web hosting servers you can use SSI (Server Side Includes) in shtml, or shtm files.
However, you need to use SSI in your .html and htm files. There is an easy solution for this.
Just add the following line in your .htaccess file:
AddHandler server-parsed .html .htm
This line will tell the server to parse your .htm file as SSI and execute any SSI directives you have there.
You can also use .htaccess to enable CGI scripts execution as well as change the default extension for such files as well.
For Perl/CGI scripts you will need:
AddHandler cgi-script .cgi .pl
To make PHP files to be parsed as PHP when PHP is running as module
AddType application/x-httpd-php .html .htm
To make PHP files to be parsed as PHP when PHP is running as CGI (suexec, etc)
AddHandler application/x-httpd-php .html .htm
- How to block users from accessing your site based on their IP address
- How to prevent or allow directory listing?
- How to change the error documents – 404 Page Not Found, etc
- Using .htaccess for password protecting your folders
- Using .htaccess to block referrer spam
- Disable Hot-Linking of images and other files
- Redirect URLs using .htaccess
- Introduction to mod_rewrite and some basic examples
- Force SSL/https using .htaccess and mod_rewrite
- 301 Permanent redirects for parked domain names
- Enable CGI, SSI with .htaccess
- How to add Mime-Types using .htaccess
- Change default directory page
- Block Bad robots, spiders, crawlers and harvesters
- Make PHP to work in your HTML files with .htacess
- Change PHP variables using .htaccess
- HTTP Authentication with PHP running as CGI/SuExec
- Force www vs non-www to avoid duplicate content on Google
- Duplicate content fix index.html vs / (slash only)
Comments 6 >>
randy s Said,
Action Extension_Type /cgi-bin/php.dat
This works correctly on our Network Solutions Unix package. PHP is running as CGI with path as show to the dat file.
Thank you!
Apr 11, 2008 @ 09:45
AddHandler extension_Type .html .htm .php3 .php4Action Extension_Type /cgi-bin/php.dat
This works correctly on our Network Solutions Unix package. PHP is running as CGI with path as show to the dat file.
Thank you!
S P Arif Sahari Wibowo Said,
Options +ExecCGI
AddHandler cgi-script cgi pl
Nov 21, 2008 @ 11:04
Just addhandler may not enough to allow CGI run. From Apache manual (http://httpd.apache.org/docs/2.2/howto/htaccess.html), you need both comman below:Options +ExecCGI
AddHandler cgi-script cgi pl
Calling Cards Said,
Jan 13, 2009 @ 12:06
Each server is different..I had them combined until it work.
uttam Said,
can any one hekp me
Options +ExecCGI
AddHandler cgi-script cgi pl
Jul 10, 2009 @ 07:44
I have written below lines in my .htaccess file but still there is error to execute CGI files.can any one hekp me
Options +ExecCGI
AddHandler cgi-script cgi pl
| Previous: 301 Permanent redirects for parked domain names | Next: How to add Mime-Types using .htaccess |

AddHandler extension_Type .html .htm .php3 .php4
Action Extension_Type /cgi-bin/php.dat