2013-03-28 18 views
1

與web.py匹配REQUEST_URI我試圖部署具有mod_cgid模塊中的Apache我的web.py應用。SCRIPT_NAME不存在於Apache cgid進行模塊

我在urls.py中定義的URL這樣

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

這是我的應用程序啓動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() 

我的Apache配置看起來像這樣

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

當我嘗試用localhost/app /來打我的服務器時,它總是顯示notfound頁面和日誌,我看到消息話題「警告:SCRIPT_NAME不匹配REQUEST_URI」

然後我試圖打印這兩個變量在NOTFOUND網頁它的自我和我/app/webstart.py和/應用/分別。

如何讓我的應用程序工作時,我與本地主機/應用程序訪問/?

回答

1
DirectoryIndex webstart.py 

您已經在Apache配置中爲目錄訪問指定了默認主頁。所以當你訪問像URL這樣的目錄時,例如。 localhost/app/,Apache將其視爲localhost/app/webstart.py,然後將請求發送到web.py.嘗試從Apache配置中刪除該條目並重新啓動Apache守護進程。

更新

當你deploy web.py through CGI,你有服務器http://localhost/webstart.py的條目,因爲你有ScriptAlias/是你的CGI腳本目錄。 webstart.py中的路由定義在該URL之後。所以你應該訪問http://localhost/webstart.py/app/你的/app/路線。您需要一些mod_rewrite的定義才能獲得像http://localhost/app/這樣的網址。

+0

我刪除了,並沒有工作。它會產生以下錯誤消息。 「AH01265:嘗試調用目錄爲腳本」 – thefourtheye 2013-03-28 08:37:43

+0

@thefourtheye抱歉,我的錯。我已經更新了答案。 – 2013-03-28 09:27:36

+0

其實我可以像這個localhost/app/webstart.py /那樣訪問它,但不能訪問靜態文件夾。現在閱讀關於mod_rewrite – thefourtheye 2013-03-28 09:39:47