V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
aaa0009
V2EX  ›  问与答

Nginx 如何内部调用不同的文件的内容?比如, /robots.txt, 实际显示 1-robots.txt 的内容?

  •  
  •   aaa0009 · Dec 25, 2016 · 3130 views
    This topic created in 3410 days ago, the information mentioned may be changed or developed.
    6 replies    2016-12-25 12:11:56 +08:00
    ericls
        1
    ericls  
       Dec 25, 2016 via iPhone   ❤️ 1
    try files
    aaa0009
        2
    aaa0009  
    OP
       Dec 25, 2016
    @ericls 但是这样写不行啊:
    location = /robots.txt {
    try_files /ii-robots.txt;
    }

    会报错,并且, robots.txt 也是存在的。
    mrytsr
        3
    mrytsr  
       Dec 25, 2016 via Android   ❤️ 1
    alias
    aaa0009
        4
    aaa0009  
    OP
       Dec 25, 2016   ❤️ 1
    @mrytsr 怎样是 404 ,如何解决:
    location /robots.txt {
    alias /1-robots.txt;
    }
    aaa0009
        5
    aaa0009  
    OP
       Dec 25, 2016
    @aaa0009 原来是需要绝对路径。
    mrytsr
        6
    mrytsr  
       Dec 25, 2016 via Android
    @aaa0009 自己百度
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3146 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:32 · PVG 22:32 · LAX 07:32 · JFK 10:32
    ♥ Do have faith in what you're doing.