Apache : Display perl script as a text
I have Perl files with no extension (not in the format of .pl) I need to execute them when I click them not open them as a plain text.
when I add pl extension to them. they work successfully. (when I added in apache.conf
AddHandler cgi-script .cgi pl
but I need to know if there's a way to execute them without adding the extension
You can use SetHandler to decide what Apache treats as a cgi-script.
In apache configuration, add this and reload/restart Apache:
<Directory /path/to/directory/with/perl-files> SetHandler cgi-script </Directory> # Or <DirectoryMatch>, <Location>, <FilesMatch> or similar directives
In the directory itself, add file .htaccess with content:
This will make Apache treat everything in the directory as a cgi-script and try to execute it regardless of file extension.
The .htaccess solution might need additional permissions in apache configuration, (like AllowOverride SetHandler) see Apache Doc for AllowOverride