Hello,

I have an Apache server with mod_wsgi, and I would like to host web2py
alongside a variety of other things. For example:

http://example.com/   hosts a PHP website. Might link to things like /
about.php, /users/view.php, etc
http://example.com/files   a standard Apache listing of files in a
directory
http://example.com/myapp1   a web2py application named "myapp1"
http://example.com/myapp2   a web2py application named "myapp2"

The Apache/mod_wsgi deployment example in the web2py book uses:

  WSGIScriptAlias / /users/www-data/web2py/wsgihandler.py

which effectively causes web2py to take over the root of the URL
hierarchy. In that case,

http://example.com/myapp1
http://example.com/myapp2

work as expected, but you've locked yourself out of serving any non-
web2py content on the server.

My workaround was to do this:

  WSGIScriptAlias /web2py /users/www-data/web2py/wsgihandler.py

to get web2py content namespaced under /web2py, and then use
mod_rewrite to create nicer URLs into the /web2py location; e.g.:
  RewriteRule ^/myapp1(/.*)?$ /web2py/myapp1$1 [PT,L]

However, now the app is accessible through two URLs: http://example.com/myapp1
or http://example.com/web2py/myapp1. Moreover, any of my web2py
applications are accessible via /web2py/[appname] even if I only want
to expose a select few applications on a particular server.

I can restrict which applications are accessible via something like:
  <Location /web2py>
    Order Allow,Deny
    Deny from all
  </Location>

and then explicitly allow only those apps I want to expose. Then I can
(sort of) get rid of the redundant /web2py/[appname] URL with
something like:

  RewriteRule ^/web2py/myapp1 /myapp1 [R,L]

but now it seems like we've gone to a lot of work to accomplish a
fairly simple task.

Is anyone aware of a cleaner way to expose one or a few web2py apps
without lettings web2py take over the entire root URL namespace?

Thanks,
Kevin

Reply via email to