在部署版本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