CI框架的静态文件加载问题,LNMP环境,求帮忙写一个重写规则

文件目录结构:
图片描述

在视图文件中引入js,css文件:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>welcome</title>
    <script type="text/javascript" src="static/js/main.js"></script>
    <link rel="stylesheet" type="text/css" href="static/css/main.css" />
</head>
<body>
    <h1>hello</h1>
</body>
</html>

访问视图可以正常加载,css ,js没有效果,已经去掉index.php;
http://wb.vxndy.com/welcome/index
nginx配置文件:

server {
        listen       80;
        server_name  www.ci.dev ci.dev;
        root   "D:/phpStudy/WWW/ci";
        index  index.html index.htm index.php;
        location / {
            if (!-e $request_filename){
               rewrite ^/(.*)$ /index.php/$1 last;
            }
            #autoindex  on;
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

求可以正确加载静态文件的nginx规则;

阅读 3.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题