我在 Vue js 应用程序中在 Django 应用程序的生产模式下使用历史记录模式。因此,我必须通过在 nginx 上使用 try_files 命令来响应所有 get 请求。但它不起作用。我尝试了很多文档来解决它,不幸的是,我不能。
我的网站配置:
server {
listen 80;
server_name www.example.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/usr/projects/example;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/usr/projects/example/example.sock
}
location / {
root /home/usr/projects/example;
try_files $uri $uri/templates/index.html $uri.html=404
}
}
请帮我找出代码中的错误,提前致谢。
主要网址:
from django.contrib import admin
from django.urls import path,include
urlpatterns = [
path('',include('home.urls')),# ... others ursl
]
主页网址:
from django.urls import path
from . import views
urlpatterns = [
path('',views.spa,name='home'),# ... others ursl
]
索引视图:
from django.shortcuts import render
def spa(request):
return render(request,'spa/index.html')