我有一个正在运行的 nginx 实例,其配置如下。目前,它解析为服务器的根 URL。我如何更改配置,使其解析为http://服务器IP/文件夹名称代替http://服务器IP
Server {
listen 80;
root /var/www;
index /_h5ai/server/php/index.php;
try_files $uri $uri/ =404;
location /_h5ai/ {
root /usr/share/h5ai/;
location /_h5ai/server/php/index.php {
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}
}
}
(抱歉问了个愚蠢的问题,我刚刚学习 nginx)
答案1
尝试使用这个配置:
server {
listen 80 default_server;
root /var/www;
index /_h5ai/server/php/index.php;
try_files $uri $uri/ =404;
location /FolderName {
alias /usr/share/h5ai/_h5ai/;
}
location /FolderName/server/php/index.php {
alias /usr/share/h5ai/_h5ai/;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}
}