开发者

Web.py URL Mapping not accepting '/'

So every web.py tutorial I've seen includes this line:

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

And then, later on, the index class is defined with a GET function and so on. My problem is, this doesn't work. Using the code above, I get a 404 error. Using the following mapping works:

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

But that's going to catch, at least at first, every single possible URL, and I want only an access to the domain root to be handled by "index." Halp?

Some basic info:

Python 2.6, web.py 0.3, Apache 2.2 with mod_wsgi

Not sure what else would be useful, so if there is something important I can add (the VirtualHost from Apache, maybe?) please ask and I'll add it here.

EDIT: Including my Apache VirtualHost config:

<VirtualHost *:80>
    ServerName dd.sp4.us
    DocumentRoot /home/steve/www/nov2010/public/
    ErrorLog /home/steve/www/nov2010/log/error.log
    CustomLog /home/steve/www/nov2010/log/access.log combined

    WSGIScriptAlias / /home/steve/www/nov2010/app
    Alias /static /home/steve/www/nov2010/public

    <Directory /home/steve/www/nov2010/app>
        SetHandler wsgi-scr开发者_如何学Goipt
        Options ExecCGI
    </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>


For background read:

http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines

Presuming you only have the one WSGI application to be mounted at root of site and only static files or other resources are under /static, then instead of:

WSGIScriptAlias / /home/steve/www/nov2010/app
Alias /static /home/steve/www/nov2010/public

<Directory /home/steve/www/nov2010/app>
    SetHandler wsgi-script
    Options ExecCGI
</Directory>

AddType text/html .py

<Location />
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_URI} !^/static
    RewriteCond %{REQUEST_URI} !^(/.*)+code.py/
    RewriteRule ^(.*)$ code.py/$1 [PT]
</Location>

use:

Alias /static /home/steve/www/nov2010/public

WSGIScriptAlias / /home/steve/www/nov2010/app/code.py

<Directory /home/steve/www/nov2010/app>
Order allow,deny
Allow from all
</Directory>

You are mixing up multiple ways of configuring mod_wsgi which shouldn't be used together.

If your requirements are something else, you are going to have to be clearer about what you want to happen.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜