首页  >  问答  >  正文

nginx中设置虚拟目录的问题?

server {
        listen       80;
        server_name  localhost;
    index index.html index.htm index.php;
    root /alidata;
    location ~ .*\.(php|php5)?$
    {
        #fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires 30d;
    }
    location ~ .*\.(js|css)?$
    {
        expires 1h;
    }
    location / {
     if (!-e $request_filename)
     {
         rewrite (.*) /index.php;
     }
   }
}

我现在是root /alidata;即指向alidata下的根目录。

如果只指向两个/alidata/A,/alidata/B,如何设置?

ringa_leeringa_lee2713 天前339

全部回复(1)我来回复

  • PHP中文网

    PHP中文网2017-05-16 17:18:45

    你可以给每个location添加正则来匹配A和B,比如 location/(A|B)/代替~

    回复
    0
  • 取消回复