2018-06-04 23:00:52 3671次浏览 5条回答 0 悬赏 40 金钱

Ngnix已经按照网上说法配置了,

location / {
    # Redirect everything that isn't a real file to index.php
    try_files $uri $uri/ /index.php?$args;
}

访问 localhost/web/ 会自动掉转到 localhost/web/site/login 说明还是解析到了. 我试着在 /web/index.php 里面输出一个hello, 并且屏蔽了这个里面启动Yii的代码(new yii\web\Application($config))->run();, 发现也能正常访问.

用的是LNMP一键安装包!

最佳答案

  • 买醉九州 发布于 2018-06-05 19:01 举报

    如果请求即不是一个文件,也不是一个目录

    if (!-e $request_filename)
    {
        #地址作为将参数rewrite到index.php上。
        rewrite ^/(.*)$ /index.php?$1;
    }
    

    在vhost.conf中配置的路由中 location前边加上这一段就可以了

  • 回答于 2018-06-05 10:48 举报

    据说是需要nginx.vhost里边重写

    1 条回复
    回复于 2018-06-05 12:49 回复

    怎么重写,能指点下吗?

  • 回答于 2018-06-05 15:04 举报

    你是用公司代码的话 需要问公司里他们定义的路由规则

  • 回答于 2018-06-05 20:46 举报

    vi /usr/local/nginx/conf/vhost/域名.conf
    把下面填上即可

    location / {
        if (!-e $request_filename) {
            rewrite ^(.*)$ /index.php?s=$1 last;
            break;
        }
    }
    
  • 回答于 2018-06-14 08:46 举报

    lnmp一键安装包么,建议仔细阅读添加虚拟机时的说明文档,尤其对于跨目录访问权限的设置---open_basedir

您需要登录后才可以回答。登录 | 立即注册
秀小川
主管

秀小川

注册时间:2017-08-16
最后登录:2022-05-23
在线时长:20小时47分
  • 粉丝1
  • 金钱455
  • 威望0
  • 积分655

热门问题