Python Django和Apache一起处理管理页面,但为所有其他URL提供404

Python Django和Apache一起处理管理页面,但为所有其他URL提供404,python,django,apache,Python,Django,Apache,我是django初学者 我尝试使用apache2(2.4.7)从本地服务器部署django(1.10)站点 港口打开了 管理员页面已正确打开,但所有其他视图均未打开 url.PY from django.conf.urls import url,include from django.contrib import admin from django.views.generic import RedirectView from django.conf import settings urlpatt

我是django初学者

我尝试使用apache2(2.4.7)从本地服务器部署django(1.10)站点 港口打开了

管理员页面已正确打开,但所有其他视图均未打开

url.PY

from django.conf.urls import url,include
from django.contrib import admin
from django.views.generic import RedirectView
from django.conf import settings
urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^treedump/',include('treedump.urls')),
    url(r'^$', RedirectView.as_view(url='/treedump/', permanent=True)),
    url(r'^accounts/', include('django.contrib.auth.urls')),
 ]
TREEDUMP.url

from django.conf.urls import url

from . import views

urlpatterns=[
    url(r'^$',views.index,name='index'),
    url(r'printx$',views.printx,name = 'printx'),
    url(r'download$',views.download,name = 'download'),

    ]
APACHE中的.CONF文件

 <VirtualHost *:80>
     ServerName *********
     DocumentRoot /var/www/html/

  Alias /static /data1/ekmmsc/webapp/ekmmsc/static

  WSGIDaemonProcess ekmmsc python-path=/data1/ekmmsc/webapp/ekmmsc python-     home=/data1/ekmmsc/webapp/ekmmsc/ekmmscenv
  WSGIProcessGroup ekmmsc
  WSGIScriptAlias /ekmmsc /data1/ekmmsc/webapp/ekmmsc/ekmmsc/wsgi.py

  # Other directives here ...
  <Directory "/var/www/html/">
    allow from all
    order allow,deny
    AllowOverride All
    AddType text/css .css
    AddType text/javascript .js
  </Directory>


  <Directory "/data1/ekmmsc/webapp/ekmmsc/static">
    Require all granted
  </Directory>

  <Directory "/data1/ekmmsc/webapp/ekmmsc/ekmmsc">
    <Files wsgi.py>
       Require all granted
    </Files>
  </Directory>



  </VirtualHost>

服务器名*********
DocumentRoot/var/www/html/
别名/static/data1/ekmmsc/webapp/ekmmsc/static
WSGIDaemonProcess ekmmsc python path=/data1/ekmmsc/webapp/ekmmsc python-home=/data1/ekmmsc/webapp/ekmmsc/ekmscenv
WSGIProcessGroup ekmmsc
WSGIScriptAlias/ekmmsc/data1/ekmmsc/webapp/ekmmsc/ekmmsc/wsgi.py
#这里的其他指令。。。
通融
命令允许,拒绝
允许超越所有
AddType text/css.css
AddType text/javascript.js
要求所有授权
要求所有授权
输出

找不到

在此服务器上找不到请求的URL/treedump/

任何帮助都将不胜感激,我已经为此工作了将近两天。
请帮助。

您应该在视图中使用
pattern\u name
而不是
url
。这将使Django按名称查找URL,而不是使用硬编码的值,因此它将考虑脚本前缀

RedirectView.as_view(pattern_name='index', permanent=True)),

您应该在视图中使用
pattern\u name
而不是
url
。这将使Django按名称查找URL,而不是使用硬编码的值,因此它将考虑脚本前缀

RedirectView.as_view(pattern_name='index', permanent=True)),

您在treedump.url中有什么内容?您好,Daniel,请查找更新treedump.url文件。您的站点位于/ekmmsc下,因此需要转到/ekmmsc/treedump/。如果您使用Django的URL生成工具,这将自动发生。Daniel,那么如何将其重定向到该特定URL,因为我想将其托管在ekmmsc中,即,我希望/ekmmsc重定向到/ekmmsc/treedump。treedump.URL中有什么内容?你好,Daniel,请查找更新treedump.url文件。您的站点位于/ekmmsc下,因此需要转到/ekmmsc/treedump/。如果您使用Django的URL生成工具,这将自动发生。Daniel,那么如何将其重定向到该特定URL,因为我想将其托管在ekmmsc中,即,我希望/ekmmsc重定向到/ekmmsc/treedump.Daniel,我可以为每个URL添加一个类似xxx/ekmmsc/的默认值吗,因为django别名是在apache conf中给出的/ekmmsc。所以,如果我重定向它,它将在没有ekmmsc的情况下运行,并且会出现404错误。所以,你能建议如何为每个url正则表达式添加这个默认标记吗?我不理解你的评论。如果您使用我提供的代码,Django将自动添加前缀。谢谢daniel,但现在我收到了以下错误:OSError at/treedump/Errno 2]没有这样的文件或目录异常位置:/usr/local/lib/python2.7/site-packages/Django-1.10.7-py2.7.egg/Django/utils//os.py in abspathu,第31行……请帮助我,这似乎是一个单独的问题。请提出一个新问题并显示TreeUp视图的代码。Daniel,我是否可以为每个url添加一个默认值,如xxx/ekmmsc/,因为在apache conf中提供了django别名/ekmmsc。因此,如果我重定向,它将在没有ekmmsc的情况下运行,并且将出现404错误。所以,你能建议如何为每个url正则表达式添加这个默认标记吗?我不理解你的评论。如果您使用我提供的代码,Django将自动添加前缀。谢谢daniel,但现在我收到了以下错误:OSError at/treedump/Errno 2]没有这样的文件或目录异常位置:/usr/local/lib/python2.7/site-packages/Django-1.10.7-py2.7.egg/Django/utils//os.py in abspathu,第31行……请帮助我,这似乎是一个单独的问题。请提出新问题并显示TreeUp视图的代码。