【发布时间】:2021-12-14 18:39:06
【问题描述】:
假设一个网站有这样的文件夹结构
/index.php
/<public>
dikpic.jpeg
当有人访问该网站时,我希望物理网络根指向/public,
喜欢mywebsite.com/dikpic.jpeg
(没有 URL 重写)。
这可以通过root /myuser/public; 命令实现。
但我也想从这个目录外加载 index.php 文件:
index /myuser/index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* \.php$ {
fastcgi_pass unix:/run/php/php7.4-fpm-myuser.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
问题在于位置尝试文件块假定/ 是网络根目录:(
有什么办法吗?
我还应该指出,index.php 是网站上唯一的脚本。 所以我真的不在乎是否忽略了任何其他对 .php 文件的请求。 index.php 处理 url 重写的东西...
【问题讨论】:
-
不是真的,对不起...
-
为什么你的 index.php 需要在你的公共目录之外?你的公共目录是你的 web 根目录,如果你的 index.php 是 index.html 的 php 版本,那么公共目录是唯一明显的地方。
-
因为服务器托管多个具有相同索引的网站,我想有一个文件,而不是复制到每个网站