Django的Apache的重定向问题 [英] Django Apache Redirect Problem

查看:149
本文介绍了Django的Apache的重定向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在配置我的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/...?

感谢您的帮助。

推荐答案

您可以尝试:


  1. 改变当前域yourdomain.tld / cflow的在地王框架。这很容易使用Django admin或du​​mpdata / loaddata manage.py命令来完成。

  1. 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.

您的网站似乎是使用<一个href=\"http://docs.djangoproject.com/en/1.0/topics/auth/#the-login-required-decorator\">login_required装饰。在这种特殊情况下可添加到 settings.py

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的重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆