Django Apache Redirect Problem

ⅰ亾dé卋堺 提交于 2019-12-17 19:34:46

问题


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.

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>

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.

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/...?

Thanks for any help.


回答1:


Things to try:

  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.

  2. Looks like your site is using login_required decorator. In that particular case you can add to settings.py:

    LOGIN_URL = '/cflow/accounts/login/'



来源:https://stackoverflow.com/questions/1036186/django-apache-redirect-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!