I'd like to use perlscripts without their extension. f.e. "index" instead of "index.pl".

Changing the DefaultType-directive from text/plain to application/x-perl didn't do the trick. Instead of running the script the server offered to download its source.

I'm not exactly sure if changing this directive is the right approach. Telling apache to read the shebang-line when there is no extension sounds much better to me.

I hope someone with more experience on this topic can help me out.

  • 1
    My gut feeling is that it would be better to do an internal rewrite from a URL with no extension to ".pl", but of course if your perl scripts don't have an extension...?
    – MrWhite
    Aug 1, 2012 at 8:59
  • @w3d is right, or if you do this because you dont like the .pl you can add an extension like .list or .page or .whateveryoulike and work with it like perl. Aug 1, 2012 at 11:22
  • Hmmm... I'm trying to do something like blabla.example.xyz/myapp/folder1/folder2 where "myapp" is my perlscript. To the enduser it will look like navigating through a folder structure. But "myapp" could also be a php-site or python... or whatever... it just shouldn't show up.
    – tiMbeRdroP
    Aug 6, 2012 at 0:32

2 Answers 2


It all really depends on how did you write your Perl script (which framework, which style) and how do you invoke them (CGI, FastCGI, mod_perl, PSGI, HTTP reverse proxy, etc.) but usually every Apache handler that you add per file extension you can also add based on a directory or location.

For good examples on different ways of deploying Perl scripts on Apache using the Catalyst Web framework see: http://wiki.catalystframework.org/wiki/deployment#Apache

For examples on how to deploy Perl scripts using the Mojo framework see: https://github.com/kraih/mojo/wiki/Apache-deployment

If you use CGI then your scripts will be run by perl as long as they are executable and have something like #!/usr/local/bin/perl in the hashbang line but it's not really recommended to use CGI any more, unless you understand the performance issues.

If you use ModPerl::Registry you can use a config like this example:

# httpd.conf
PerlModule ModPerl::Registry
Alias /perl/ /home/httpd/perl/
<Location /perl>
    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    #PerlOptions +ParseHeaders
    #PerlOptions -GlobalRequest
    Options +ExecCGI

and have everything in /perl be interpreted as Perl script and run by mod_perl.

If you use PSGI or directly HTTP with a reverse proxy, you have to configure Apache to proxy everything from some location to your application using HTTP.

There are really too many ways to do it to enumerate every one of them not knowing your configuration.


You have to use rewrite to map scripts without a name to their perl equivalent. For example http://EXAMPLE.COM/mypage would map to mypage.pl. (where example.com is the site your domain)

  • site.com is a real website and you are posting a nonexistent links to it that people click, spiders crawl and it just pollutes the error logs of some people. Use example.com, example.net, example.org, and example.edu - see RFC 2606 section 3: Reserved Example Second Level Domain Names.
    – rsp
    Oct 31, 2012 at 12:48
  • I was using site.com as my example site (fill in the blank). Personally, in some cases i redirect the visitor or bot to our corp homepage. Other times to an error page. and many times to GOOGLE.com
    – Frank
    Nov 12, 2012 at 12:22
  • I understand your intention but you shouldn't use real people's websites as examples especially if you post them as active links to nonexistent pages. You should use the domains reserved for that purpose in RFC 2606, see my comment above.
    – rsp
    Nov 12, 2012 at 12:47
  • @rsp - you are 100% correct. Thanks for cleaning it up. I edited the response to reflect your comment.
    – Frank
    Nov 13, 2012 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.