thefourtheye
thefourtheye

Reputation: 239573

SCRIPT_NAME does not match REQUEST_URI with web.py in apache cgid module

I am trying to deploy my web.py application in Apache with mod_cgid module.

I have defined the urls like this in urls.py

urls = (
    '/app/', 'index.index',
    '/', 'index.index'
)

This is where my application starts webstart.py

import web, urls, sys, os
def notfound():
    return web.notfound()
if __name__ == "__main__":
   app = web.application(urls.urls, globals())
   app.notfound = notfound
   app.run()

My Apache configuration looks like this

<Directory "dirname">
   Options +ExecCGI +FollowSymLinks +Indexes
   Order allow,deny
   Allow from all
   Require all granted
   DirectoryIndex webstart.py
</Directory>

When I try to hit my server with localhost/app/, it always shows the notfound page and in the logs, I see the messsage "WARNING: SCRIPT_NAME does not match REQUEST_URI"

And then I tried to print those two variables in the notfound page it self and I got /app/webstart.py and /app/ respectively.

How do I let my application work when I access it with localhost/app/?

Upvotes: 1

Views: 883

Answers (2)

thefourtheye
thefourtheye

Reputation: 239573

Couldnt solve this problem, so used wsgi module. This is how I did it... http://dfourtheye.blogspot.in/2013/03/deploying-webpy-application-in-apache.html

Upvotes: 0

Arie Xiao
Arie Xiao

Reputation: 14082

DirectoryIndex webstart.py

You've specified default home page for directory access in Apache configuration. So when you access some directory like URL, eg. localhost/app/, Apache treat this as localhost/app/webstart.py and then send the request to web.py. Try remove that entry from Apache configuration and restart Apache daemon.

Update:

When you deploy web.py through CGI, you got an entry for the server http://localhost/webstart.py, given that you have ScriptAliased / to be your CGI script directory. And the route definitions in webstart.py comes after that url. So you should visit http://localhost/webstart.py/app/ for your /app/ route. You'll need some mod_rewrite definitions to get urls like http://localhost/app/.

Upvotes: 1

Related Questions