【发布时间】:2017-05-07 22:17:11
【问题描述】:
server {
listen <...:...>;
server_name <...>;
root /var/www/html/myserver;
location /myproject {
try_files $uri /myproject/web/app.php$is_args$args;
}
location ~ ^/myproject/web/(app_dev|config)\.php(/|$) {
fastcgi_pass <...php-fpm...>;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
location ~ ^/myproject/web/app\.php(/|$) {
fastcgi_pass <...php-fpm...>;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
location ~ \.php$ {
return 404;
}
}
当我尝试去myserver.com/myproject/web时,我可以看到我的项目
我想通过myserver.com/myproject 访问我的项目。
但是这个 url 给出 404(在 Symfony 中):
No route found for "GET /myproject/"
我在配置文件中添加了这个重写规则,但它不起作用:
rewrite ^/myproject(/|$)$ /myproject/web last;
【问题讨论】:
标签: symfony nginx configuration subdirectory