I added this to my .htaccess file:
AddHandler fcgid-script .test
(I'm using FastCGI / VirtualMin / WebMin)
And crated a test.test file with the contents;
<?php echo "test"; ?>
This results in an internal server error and this message in the error log:
[Thu Apr 16 14:12:57.631287 2015] [fcgid:warn] [pid 2646] (104)Connection reset by peer: [client xxxx:53595] mod_fcgid: error reading data from FastCGI server
[Thu Apr 16 14:12:57.631402 2015] [core:error] [pid 2646] [client xxxx:53595] End of script output before headers: test.test
What am I doing wrong? I tried using different handler namees like x-httpd-php or x-httpd-php5 but that doesn't do anything at all.
I also tried:
<FilesMatch "\.test$">
SetHandler fcgid-script
</FilesMatch>
but it has the same internal server error.
Tested and verified to work:
Because you mentioned you are using Webmin, I tailored my answer for Webmin. You can do this by editing Apache's configuration through shell as well.
I will note that it is generally preferable to edit Apache's configuration, and in this case probably unavoidable, as I do not believe you can make this sort of edit in .htaccess
. Although there may be a hack I'm unfamiliar with, a server admin would probably want to keep this locked inside of apache configuration. Thoughts of .htaccess
files with rogue file extensions flying around on a per-directory basis not only sounds slow, but also highly insecure.
I installed Apache on Ubuntu 14.04 through VirtualBox. I added Webmin and FastCGI.
I took the following steps:
<Directory />
#Your SetHandler script here
#(@MrTux's script works here but NOT IN .htaccess)
Require all granted
</Directory>
I will note that SetHandler passes some headers, so if you declare this in .htaccess
there is a chance that headers have already been sent which is what is triggering your error. Again, .htaccess
is not the preferred way to set rules if you have control over your system. In this case it would probably cause security issues anyway.