【发布时间】:2018-12-11 06:28:10
【问题描述】:
我的项目要求是从 Slim 框架 (index.php) 启动一个 angular(v6)/ionic(v4) 应用程序(index.html)。 根文件夹结构如下图所示:
'www' 是 Slim index.php 所在的根目录。在“www”内是添加了角度构建文件(index.php)的应用程序文件夹。 要求是所有请求都应该通过根文件夹中的 Slim index.php,并且基于一些会话逻辑,我们必须路由或启动 Angular 应用程序 (index.html)。
现在,“https://domain/”通过 index.php。但, 'https://domain/app/' 直接启动 Angular 应用程序 (index.html)。
如何配置 nginx,让 Slim index.php 在根目录中处理所有请求?
server {
server_name <domain>;
root /var/www/<some name>/public/www/;
index index.php index.html index.htm;
access_log /var/log/nginx/<some name>.log;
error_log /var/log/nginx/<some name>.log;
sendfile off;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ index.php /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 36000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
谢谢
【问题讨论】:
-
Mybe,您可以限制对
app文件夹的访问,或将所有https://domain/app/请求重定向到https://domain,如果这能解决您的问题,我可以给您代码 -
嗨@ABDELLATIFLAKEHAL,如果你能分享代码会很有帮助。我的要求是限制对 app 文件夹的访问并重定向到 root。我尝试过重定向和重写但没有成功,但这可能是因为我不专业。
标签: nginx slim nginx-location nginx-config