Nginx 

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

Apache

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>

 

Apachei还需要加上如下代码,解决无法从header中huoquAuthorization参数,即登陆可以获取token,Header头中用Authorization 值为Bear+token却拿不到用户信息,但是通过url?token=的形式却可以

如果用php artisan serve启动的服务则不存在此问题

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

完整代码

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
  SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</IfModule>