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?

link|improve this question

69% accept rate
feedback

1 Answer

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>
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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