【问题标题】:Wrong path in nginx to static pagenginx到静态页面的路径错误
【发布时间】:2019-02-15 16:40:36
【问题描述】:

虽然我有 django 中的应用程序,但我想设置一个静态页面。使用 nginx。但我得到一个错误:

[alert] 100983#0: *439266 "/path_to_page_on_server/press_page.htmlindex.html" is not a directory,

这是我的网址: url(r'^press/', TemplateView.as_view(template_name='press_page.html'), name='press')

这是我在 nginx 中的配置包括:

location /press/ { alias /path_to_page_on_server/press_page.html; }

我想在/press/下有页面press_page.html

【问题讨论】:

    标签: python django nginx static-pages


    【解决方案1】:

    nginx 中,您的index 值设置为index.html,因此它被附加到alias-ed 位置。

    您需要为您的自定义文件指定index,并将文件引用放在alias

    location /press/ {
        alias /path_to_page_on_server/;
        index press_page.html index.html;
    }
    

    最后一个index.html 只是一个备用,你可以根据需要删除/替换它。

    【讨论】:

    • 感谢您的回答。现在我在error.log 中的路径类似于/path_to_page_on_server/press_page.htmlpress_page.html。双press_page.html。我也删除了index.html
    • 您不是只使用nginx 吗?请求是否也路由到django?你的实际/path_to_page_on_server/ 是什么?
    • 对不起,我弄错了,一切都很完美。非常感谢,你度过了我的周末:)
    • @user9192656 没问题。享受你的周末:)
    猜你喜欢
    • 2016-04-22
    • 2019-08-04
    • 1970-01-01
    • 1970-01-01
    • 2015-08-12
    • 1970-01-01
    • 1970-01-01
    • 2015-07-13
    • 2017-02-08
    相关资源
    最近更新 更多