Home  >  Q&A  >  body text

Problem setting virtual directory in 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;
     }
   }
}

I am now root /alidata; that is, pointing to the root directory under alidata.

If it only points to two /alidata/A and /alidata/B, how to set it?

ringa_leeringa_lee2713 days ago335

reply all(1)I'll reply

  • PHP中文网

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

    You can add regular rules to each location to match A and B, such as location/(A|B)/代替~

    reply
    0
  • Cancelreply