thinkphp Nginx偽靜態

zjMars發表於2024-07-22
  • 過濾api字首
    location / {
    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
    add_header Access-Control-Allow-Headers 'DNT,Keep-Alive,User-Agent,Cache-Control,Content-Type,Authorization';

    if ($request_method = 'OPTIONS') {
    return 204;
    }

if (!-e $request_filename){
rewrite ^/api/(.*)$ /index.php?s=$1 last; break;
}
}

  • 不過濾api
    location / {
    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
    add_header Access-Control-Allow-Headers 'DNT,Keep-Alive,User-Agent,Cache-Control,Content-Type,Authorization';

if ($request_method = 'OPTIONS') {
return 204;
}

if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}

相關文章