所以我见过的每个 web.py 教程都包含这一行:
urls = (
'/', 'index',
)
然后,稍后,使用 GET 函数等定义索引类。我的问题是,这不起作用。使用上面的代码,我得到一个 404 错误。使用以下映射工作:
urls = (
'/.*', 'index',
)
但这至少在一开始会捕获每一个可能的 URL,我只希望“索引”处理对域根目录的访问。哈普?
一些基本信息:
Python 2.6、web.py 0.3、带有 mod_wsgi 的 Apache 2.2
不知道还有什么有用的,所以如果我可以添加一些重要的东西(也许是来自 Apache 的 VirtualHost?)请询问,我会在这里添加它。
编辑:包括我的 Apache VirtualHost 配置:
<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-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>
</VirtualHost>