aaa0009
V2EX  ›  问与答

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

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

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