Nginx 配置通配符第一个文件夹



我正在努力让nginx conf以我们需要的方式工作。 基本上在同一域上,我们有许多应用程序,每个应用程序都在根文件夹中。当用户安装应用程序时,无法知道文件夹的名称。

location / {
try_files $uri $uri/ /index.php?$args /index.php?q=$uri&$args;
}
location /myfiles {
try_files $uri $uri/ /myfiles/index.php?$args /myfiles index.php?q=$uri&$args;
}

如果我指定第二个文件夹,它会使 myfiles 中的应用程序正常工作,URL 解析正确。如果我不这样做,则主应用程序会尝试解析 URL 并失败。

所以我想有这样的东西:

location /* {
try_files $uri $uri/ /$folderrequested/index.php?$args /$folderrequested/index.php?q=$uri&$args;
}

其中 * 是任何根文件夹,例如 myfiles、mycrm、myaccount,它将 trafic 路由到该文件夹。

欢迎任何建议和想法!

将所有应用根目录放在父目录中。

server {
listen .....;
server_name ....;
root /path/to/apps;
index index.php index.html;
location / {
}
location ~ .php {
fastcgi_pass localhost:8000;
}
}

宾果游戏。

相关内容

最新更新