.htaccess & web.py,在 SetHandler fcgid-script

问题描述 投票:0回答:2

我在根目录中有以下 .htaccess 以启动 web.py 应用程序:

allow from all
SetHandler fcgid-script
Options +ExecCGI
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.py/$1 [PT]

一切正常,除了我无法使用 css 等访问静态文件夹。

这是app.py中的代码:

import web
from getImgUrl import search

render = web.template.render('templates/')

urls = (
  '/', 'index'
)

class index:
    def GET(self):
        term = search()
        return render.index(term[0], term[1])

web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)
if __name__ == "__main__": 
    app = web.application(urls, globals())
    app.run()  
python .htaccess web.py
2个回答
0
投票

我通过在

static
文件夹中添加 .htaccess 文件来解决:

SetHandler None

0
投票

您还可以尝试上面的

RewriteRule ^static - [L]
,这意味着访问基于
RewriteRule ^(.*)$ app.py/$1 [PT]
的资源时不会发生重写(
/static
表示跳过进一步的重写规则处理)。
    

© www.soinside.com 2019 - 2024. All rights reserved.