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
访问我的项目。
但是这个网址给了404(在Symfony中):
No route found for "GET /myproject/"
我在配置文件中添加了这个重写规则,但它不起作用:
rewrite ^/myproject(/|$)$ /myproject/web last;