I have created a Laravel application which is both Web application and provides REST APIs to android and iOS platforms.
I have two route files one is api.php and other is web.php and routes\api.php routing as follows:
routes/api.php
Route::group([
'domain'=>'api.example.com',
function(){
// Some routes ....
}
);
这里可以看到配置的nginx服务块
server {
listen 80;
listen [::]:80;
root /var/www/laravel/public;
index index.php;
server_name api.example.com;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
I was be able to access my application using http://example.com
for web application and http://api.example.com/api/cities
for REST API's. But the subdomain URL contains api as prefix as given below.
http://api.example.com/api/cities
但我想像这样给我的子域加http://api.example.com/cities
(我想从子域名URL加remove
API前缀).
Is it right way to remove prefix api in RouteServiceProvide.php
for api routes?
或者他们是否有任何正确的方式来实现这一点?
Environment Details Laravel 5.5 (LTS) PHP 7.0