I believe I have Apache setup correctly with mod_wsgi and Rewrite Engine. I'm using web.py to serve up content. The test "Hello World" app works but the output includes the file root. Looks like this:
Hello, /var/www/example.com/application/!
I've included the config and code.
Here is the apache config:
<VirtualHost *:80>
ServerAdmin [email protected]
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/
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
<Location />
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/static
RewriteCond %{REQUEST_URI} !^(/.*)+code.py/
RewriteRule ^(.*)$ code.py/$1 [PT]
</Location>
</VirtualHost>
Python Code:
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()
Update: After playing around with the Rewrite I have come to discover that the problem is with RewriteRule ^(.*)$ code.py/$1 [PT]. The $1 (parameter) passes the root of where the python script is running plus whatever the rest of the URL is from the root url.
So an example of this would be URL:
http://{rootURL}/tom
Output:
Hello, /var/www/example.com/application/tom!
I can't figure out why the directory location of the python script is being passed in.

WSGIScriptAliasshould serve your application directly, without any need for rewriting.code.pywill never be part of the URL in such a configuration.