为啥 slim 这个路由 http://www.xxx.com/hello 注册后,当网址最后面加一个下划线, http://www.xxx.com/hello/ 就显示 404 了,怎么让路由注册后,无论最后加不加 /,都能响应一个路由请求呢。
$app->get('/hello', function ($request, $response, $args) { $response->write('hello'); return $response; });
Nginx 配置如下:
server { listen 80; listen [::]:80;
server_name www.xxx.com xxx.com;
# root /var/www/www.xxx.com;
root /slim3/website/ ;
index index.php index.html;
location / {
# try_files $uri $uri/ =404;
# try_files $uri /index.php;
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
#access_log /var/www/www.xxx.com.log;
}