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

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

作者: 风度翩翩的程序猿 | 来源:发表于2023-04-09 11:21 被阅读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;
       } 
}

相关文章

网友评论

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

      本文链接:https://www.haomeiwen.com/subject/brdbddtx.html