Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback resource for directory when using AddHandler. #184

Open
GoogleCodeExporter opened this issue Mar 1, 2016 · 0 comments
Open

Fallback resource for directory when using AddHandler. #184

GoogleCodeExporter opened this issue Mar 1, 2016 · 0 comments

Comments

@GoogleCodeExporter
Copy link

The DirectoryIndex directive allows one to define a resource which is invoked 
when accessing 
against a directory. This resource cannot however accept any additional path 
information.

The way around this is to use a rewrite rule such as:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /site.wsgi/$1 [QSA,PT,L]

Although this works, the resulting SCRIPT_NAME reflects the resource and not 
the directory. To 
get around that, one uses a fiddle such as:

def _application(environ, start_response):
    # The original application.
    ...

import posixpath

def application(environ, start_response):
    # Wrapper to set SCRIPT_NAME to actual mount point.
    environ['SCRIPT_NAME'] = posixpath.dirname(environ['SCRIPT_NAME'])
    if environ['SCRIPT_NAME'] == '/':
        environ['SCRIPT_NAME'] = ''
    return _application(environ, start_response)

In Apache 2.3 they have a FallbackResource which can be used in place of the 
rewrite rule to do 
same thing, but it still doesn't do the SCRIPT_NAME fixup. It may be desirable 
to implement a 
mod_wsgi specific mechanism the same as FallbackResource but which also does 
the 
SCRIPT_NAME fixup automatically.

Original issue reported on code.google.com by [email protected] on 4 Mar 2010 at 11:18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant