问题描述
我在配置我的Django项目使用mod_wsgi的Apache的运行。我试图在Apache目录的cflow下面运行Django的,但我遇到了问题重定向。
I'm configuring my Django project to run on Apache using mod_wsgi. I am attempting to run Django below the directory 'cflow' on apache, but am running into problem with redirects.
我的Apache的conf看起来是这样的:
My apache conf looks something like this:
...
WSGIScriptAlias /cflow "C:\Program Files\Apache Software Foundation\Apache2.2\wsgi\django.wsgi"
<Directory "C:\Program Files\Apache Software Foundation\Apache2.2\wsgi">
Order allow,deny
Allow from all
</Directory>
<Directory "C:\Projects\myproject\src">
Order allow,deny
Allow from all
</Directory>
我遇到的问题是,如果用户没有登录,对于/cflow/somepage.html一个请求会被reidrected到/accounts/login?next=/cflow/somepage.html。这个新的地址是不低于Django的根(cflow的),所以阿帕奇一个404响应没有找到。
The problem I'm running into is that if the user is not logged in, a request for /cflow/somepage.html will be reidrected to /accounts/login?next=/cflow/somepage.html. This new address is not below the django root (cflow), so apache responds with a 404 Not Found.
我的问题是我怎么能有Django的重定向映射是在Apache应用程序根目录下?即我怎么能做出/账户/ ...页面而不是/ cflow的/账户/...?
My question is how can I have the Django redirects mapped to be below the applications root directory on apache? I.e. how can I make the /accounts/... page be instead /cflow/accounts/...?
感谢您的帮助。
推荐答案
您可以尝试:
-
改变当前域yourdomain.tld / cflow的在。这很容易使用Django admin或dumpdata / loaddata manage.py命令来完成。
Change current domain to "yourdomain.tld/cflow" in the "sites" framework. It's easy to do using django admin or dumpdata/loaddata manage.py commands.
您的网站似乎是使用login_required装饰。在这种特殊情况下可添加到:
Looks like your site is using login_required decorator. In that particular case you can add to settings.py:
LOGIN_URL ='/ cflow的/帐号/登录/
LOGIN_URL = '/cflow/accounts/login/'
这篇关于Django的Apache的重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!