在部署版本Django的網站我的工作,以微軟的Azure服務的,我添加了一個頁面,這需要查詢字符串像微軟Azure追加額外的查詢字符串查詢字符串的URL
http://<my_site_name>.azurewebsites.net/security/user/?username=<some_username>&password=<some_password>
然而,我收到了404條對這個URL的迴應。於是我打開Django的調試標誌,我得到返回的頁面說:
Page not found (404)
Request Method: GET
Request URL: http://<my_site_name>.azurewebsites.net/security/user/?username=<some_username>&password=<some_password>?username=<some_username>&password=<some_password>
Using the `URLconf` defined in `<my_project_name>.urls`, Django tried these URL patterns, in this order:
^$
^security/ ^user/$
^account/
^admin/
^api/
The current URL, `security/user/?username=<some_username>&password=<some_password>`, didn't match any of these.
所以它似乎是追加查詢字符串到的是已經有相同的查詢字符串的URL的結尾。我在本地計算機上運行該站點,並在內部網絡上的iis服務器上運行該服務器,在推送到Azure之前,該服務器用於分級。這些站點部署都沒有這樣做,所以這似乎是Azure特有的。
有什麼我需要在Azure網站管理界面中設置,以防止它使用查詢字符串修改URL?有沒有什麼我做錯了與Azure使用查詢字符串?
我發現了另一個似乎與我非常相似的問題:http://stackoverflow.com/questions/12698625/query-string-get-appened-more-than-once但我不知道如何實現建議Azure上的解決方案。不是關於重寫強制https的部分,只是阻止查詢字符串加倍的部分。 – Alex 2013-03-08 20:13:40
進一步研究,我已將問題追蹤到path_info變量。我正在使用由Django提供的WSGIHandler,它使用Azure中的get_wsgi_application()作爲WSGI_HANDLER應用程序設置,如本教程所示,我應該這樣做:http://www.windowsazure.com/en-us/develop/python/tutorials/web -sites-with-django /。查看處理程序從環境變量中收到的信息,看起來好像QUERY_STRING是空的,而PATH_INFO有完整的url +查詢字符串。這似乎是導致我的問題。不知道這是否是fastcgi或iis的問題。 – Alex 2013-03-11 19:04:29
更正以上評論。 QUERY_STRING不是空的。這是我嘗試擺脫使用url重寫的雙重查詢字符串的錯誤我通過Web.config文件刪除了查詢字符串。現在問題的根源在於PATH_INFO包含查詢字符串,並且Django WSGI處理程序不期望它。 – Alex 2013-03-11 22:16:48