zoukankan      html  css  js  c++  java
  • nginx访问静态文件配置

    通过nginx访问静态文件配置,均是在server模块中配置,有两种方式:

    1、alias

    通过alias关键字,重定义路径,如

    server{
        listen 7001;
        server_name 127.0.0.1;
        location /file/ {
            alias /home/china/areas/;
        }
    }

    此时,通过浏览器访问http://127.0.0.1:7001/file/t.txt,则访问服务器的文件是/home/china/areas/t.txt

    alias可以使用正则表达式,如

    location ~  ^/test/(w+).(w+)$ {
        alise /home/china/$2/$1.$2;
    }
    

    访问/test/t.conf,则实际访问的是/home/china/conf/t.conf

    2、root

    通过root关键字,重定义路径,如

    server{
        listen 7002;
        server_name 127.0.0.1;
        location /test/ {
            root /home/china/areas/;
        }
    }

    此时,通过浏览器访问http://127.0.0.1:7001/test/t.txt,则访问服务器的文件是/home/china/areas/test/t.txt

    上述两种方法均可达到目的,区别是它们对路径的解析方式不同,alas会把指定路径当作文件路径,

    而root会把指定路径拼接到文件路径后,再进行访问。

    --------------------- 本文来自 panda-star 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/chinabestchina/article/details/73556785?utm_source=copy 

  • 相关阅读:
    Android BitmapFactory.Options
    Android TabHost
    Android 黑色样式menu
    Android Tab与TabHost
    Android Theme
    Activity 四种launchMode
    IOS xcode安装
    BaseActivity合集
    自定义BaseActivity
    Fragment 底部菜单栏
  • 原文地址:https://www.cnblogs.com/maohuidong/p/9720414.html
Copyright © 2011-2022 走看看