Wrong ScriptName in Lighttpd

When running as FastCGI application under Lighttpd, the SCRIPT_NAME and PATH_INFO are not set properly if the script runs at "/" or rewrite rules are used to make it look so.

Workaround 1

If you use rewrite rules, wrap the WSGI application and override the SCRIPT_NAME. Assuming that application is the original application, this code works:

def app(env, start):
    env['SCRIPT_NAME'] = ''
    return application(env, start)

Since Hatta 1.1.1 you can just set it in the configuration using the script_name in Script settings.

Workaround 2

If you are just running a fastcgi server on /, you have to fix the script name and path info:

def app(env, start):
    env['PATH_INFO'] = env['SCRIPT_NAME'] + env['PATH_INFO']
    env['SCRIPT_NAME'] = ''
    return application(env, start)

Fixed Bugs