0

In Apache I would like a URL "/myscript" or "/myscript?param=myparam" to execute a CGI script located at:

/usr/local/scripts/custom.pl

I have tried:

Action custom-action /usr/local/scripts/custom.pl
<Location "/myscript">
    SetHandler custom-action
</Location>

but this isn't working.

Any ideas how I can achieve the mapping of URL to script?

PP.
  • 3,316
  • 6
  • 27
  • 31

2 Answers2

2

mod_rewrite can easily do that with

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/myscript$
RewriteRules (.*) /usr/local/scripts/custom.pl

Be sure to set permissions appropriately, both the actual file permissions and a Directory Directive to allow access to that folder.

Example Directory Directive:

<Directory "/usr/local/scripts">
    Allow from All
    AllowOverride None
    Options None +ExecCGI
</Directory>
Chris S
  • 77,945
  • 11
  • 124
  • 216
0

Your handler will work if you create a file or directory in DOCUMENT_ROOT called myscript. Haven't worked out why yet, but it works!

[edit] Seems that if you're using Action to define the handler then you're effectively creating a filter through which the files in the filesystem will be passed (e.g. for DIY server-side include processing). If the target doesn't exist in the filesystem then there's nothing to pass to your script (through PATH_TRANSLATED) so the server throws an error.

kbro
  • 260
  • 1
  • 2
  • 12