I don't think it is possible to set SCRIPT_NAME to the empty string at present, unless there is some way through this logic in ap_add_cgi_vars() with values for r->uri which I don't anticipate:
else if (!r->path_info || !*r->path_info) {
apr_table_setn(e, "SCRIPT_NAME", r->uri);
}
else {
int path_info_start = ap_find_path_info(r->uri, r->path_info);
apr_table_setn(e, "SCRIPT_NAME",
apr_pstrndup(r->pool, r->uri, path_info_start));
apr_table_setn(e, "PATH_INFO", r->path_info);
}
While this particular issue seems to be a strange requirement of Plack, in general I think that configuring values/expressions for script variables would help in a number of circumstances. I could see something like
allowing you to override the logic in ap_add_cgi_vars() and ap_add_common_vars() for specific variables. nginx has something similar as the default mechanism for setting such variables, and the growing (and sometimes near-exclusive within certain communities) use of nginx in this space sometimes results in app|middleware expectations (good or bad) that can be easily met with nginx but not so with httpd.
Any thoughts out there on a SetScriptEnv directive? I don't know the .htaccess considerations here. On the one hand, an app is free to ignore/override any or all values anyway, but if someone untrusted has the ability to enable only trusted apps then this seems potentially dangerous.