当前位置 : 主页 > 编程语言 > python >

【django】另一种思路代替nginx 的rewrite

来源:互联网 收集:自由互联 发布时间:2021-06-25
需求:访问xx.com 跳转到xx.com/index 修改setting 同级别的urls.py 文件 from django.conf.urls import include, url from django.contrib import admin from django.conf import settings from testTask import views from django.views.st

需求:访问xx.com 跳转到xx.com/index

修改setting 同级别的urls.py 文件

from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
from testTask import views
from django.views.static import serve

urlpatterns = [
    url(r^admin/, include(admin.site.urls)),
    url(r^at/, include(testTask.urls)),
    url(r^static/(?P<path>.*)$, serve, {document_root:/Users/conan/vir_env/AutoTest/static/}),
    url(r^,views.index), #域名直接跳转到首页
]
网友评论