Following the tutorial at http://webpy.org/cookbook/mod_wsgi-apache, I believe you really don't need to rewrite URLs. Your apache config is then:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName foodcost.mynetwork.inside
ServerAlias foodcost.mynetwork.inside
DocumentRoot /var/www/example.com/public_html/
ErrorLog /var/www/example.com/logs/error.log
CustomLog /var/www/example.com/logs/access.log combined
WSGIScriptAlias / /var/www/example.com/application/code.py/
Alias /static /var/www/example.com/public_html
<Directory /var/www/example.com/application>
SetHandler wsgi-script
Options ExecCGI
Options +FollowSymLinks
</Directory>
AddType text/html .py
</VirtualHost>
(among other changes, note the added code.py/
to the WSGIScriptAlias
directive.)
And the file /var/www/example.com/application/code.py
is:
import web
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals(), autoreload=False)
application = app.wsgifunc()
class hello:
def GET(self, name):
if not name:
name = 'World'
return 'Hello, ' + name + '!'
if __name__ == "__main__":
app.run()
(note the added slash in the urls
tuple in the beginning.
This way there's no "code.py" showing up: