YII2.0 Restful API 记得配置服务器重写规则哦
<VirtualHost *:80>
ServerName api.apitpl.dev
DocumentRoot "/Users/michaelweixi/WWWRoot/apitpl/api/web/"
<Directory "/Users/michaelweixi/WWWRoot/apitpl/api/web/">
# use mod_rewrite for pretty URL support
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# use index.php as index file
DirectoryIndex index.php
# ...other settings...
</Directory>
</VirtualHost>