简体   繁体   English

1个使用django登录的apache虚拟主机上的2个django站点

[英]2 django sites on 1 apache virtual host with django login

I have 2 sites, both require login ( I'm using the django provided django.contrib.auth.views.login). 我有2个站点,都需要登录(我使用的是django.contrib.auth.views.login提供的django)。 When I enter http:// url /siteb , I am redirected to accounts/login and siteb is taken out of the URL creating http:// url /accounts/login. 当我输入http:// url / siteb时,我将重定向到account / login,并且siteb从创建http:// url / accounts / login的URL中删除。 But then I get an error "The requested URL /accounts/login was not found on server" 但是然后我得到一个错误“在服务器上找不到所请求的URL / accounts / login”

If I remove the login requirement and go directly to a page I can click around the site without problem (http:// url /siteb/faqa) If I have only one site in apache and use < Location "/" > I don't have a problem logging in and navigating. 如果我删除了登录要求并直接转到页面,则可以无问题地在该站点周围单击(http:// url / siteb / faqa)如果我在apache中只有一个站点并使用<Location“ /”>我不会登录和导航时遇到问题。 My issue is when I have 2 sites, both with the login redirect 我的问题是当我有2个站点时,两个站点均具有登录重定向

(Django 1.2.1, Apache 2.2.14, Python 2.6, mod_python just because that's what I was told to use) (Django 1.2.1,Apache 2.2.14,Python 2.6,mod_python只是因为我被告知要使用它)

< VirtualHost *> <VirtualHost *>

  ServerName name DocumentRoot /etc/sites < Location "/siteb"> SetHandler python-program PythonHandler django.core.handlers.modpython PythonPath "['/etc/sites', '/etc/sites/siteb'] + sys.path" PythonOption django.root /siteb SetEnv DJANGO_SETTINGS_MODULE siteb.settings PythonInterpreter siteb PythonDebug on < /Location> < Location "/sitea"> SetHandler python-program PythonHandler django.core.handlers.modpython PythonPath "['/etc/sites', '/etc/sites/sitea'] + sys.path" PythonOption django.root /sitea SetEnv DJANGO_SETTINGS_MODULE sitea.settings PythonInterpreter sitea PythonDebug on < /Location> 

< /VirtualHost> </ VirtualHost>

All of the urls should be prefixed with /sitea/ or /siteb/ 所有网址均应以/ sitea /或/ siteb /作为前缀

Django generally assumes that it is installed at the root of the website. Django通常假定它安装在网站的根目录下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM