宝塔Nginx 服务 部署php项目只能访问首页,其他都访问不了

2023-04-09  本文已影响0人  风度翩翩的程序猿
在Nginx中修改下配置

location / {
    try_files $uri $uri/ /index.php?$query_string;
    if (!-e $request_filename){ 
        rewrite ^/(.*) /index.php last; 
    }     
}
解决跨域问题
location / {
   if ($request_method = 'OPTIONS') {
          #主要是定义请求响应头问题(跨域)
          add_header 'Access-Control-Allow-Origin' * always;
          add_header 'Access-Control-Allow-Headers' * always;
          add_header 'Access-Control-Allow-Methods' * always ;
          add_header 'Access-Control-Expose-Headers' 'Authorization' always;
          return 204;
       } 
}
上一篇 下一篇

猜你喜欢

热点阅读