search

Home  >  Q&A  >  body text

php - For the same domain name, can Nginx be assigned to different websites based on directories?

Suppose there are three websites on the same serverA,B,C
but only one domain namewww.abc.com

Expectation:
Visiting www.abc.com/a can access the content of the A website,
Visiting www.abc.com/b can Access the content of B website,
visit www.abc.com/c to access the content of C website,
and so on...

NginxHow should it be configured?

My Nginx is configured like this, but it cannot achieve the desired effect:(

location /a {
    root /path/to/web/a;
    try_files $uri $uri/ /index.php;
}

location /b {
    root /path/to/web/b;
    try_files $uri $uri/ /index.php;
}

location /c {
    root /path/to/web/c;
    try_files $uri $uri/ /index.php;
}

location ~ .*\.php? {
    include                   fastcgi_params;
    fastcgi_param             SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors  on;
    fastcgi_pass              127.0.0.1:900;
}
世界只因有你世界只因有你2703 days ago840

reply all(1)I'll reply

  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-07-01 09:14:04

    Yes, through virtual directory

    reply
    0
  • Cancelreply