【发布时间】:2017-01-10 19:54:28
【问题描述】:
我想创建如下路由:
- hxxp://127.0.0.1/
- hxxp://127.0.0.1/allegro/
怎么做? 如果我去 hxxp://127.0.0.1/allegro/scripts/test.php 我看到一个空白页。如果我去 hxxp://127.0.0.1/ php 脚本正常执行,我看到 phpinfo()
我的 nginx 配置:
server {
listen 8000 default_server;
listen [::]:8000 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php7.0-fpm.sock;
}
location /allegro/ {
alias /var/www/allegro/;
autoindex on;
location ~ \.php$ {
fastcgi_split_path_info ^(.+?\.php)(/.*)?$;
fastcgi_pass unix:/run/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
}
【问题讨论】:
-
尝试
root /var/www;而不是alias /var/www/allegro/;(在location /allegro/块内) -
在 127.0.0.1/allegro/script/test.php 上仍然是空白页 :(