2016-10-18 20:16:22 4704次浏览 3条回答 0 悬赏 10 金钱

我的域名:www.kinstu.pw。现在访问需要输入www.kinstu.pw/basic/web/index.php?r=控制器/操作,这样来访问。怎样做,www.kinstu.pw可以直接访问首页的默认控制器。
服务器环境:西部数码港台linux主机

  • 回答于 2016-10-18 22:02 举报

    把你的域名指向的目录,定向到basic/web/这个目录下,nginx的配置大概是这样:

     location ~ \.php$ {
    	root 			/xxx/xxx/basic/web/;
    	......//其他配置
    }
    

    那样,访问路径就变成了www.kinstu.pw/index.php?r=控制器/操作

    如果你需要 www.kinstu.pw/basic/web/index.php?r=控制器/操作,,这样访问,那么你的配置的路径应该是这样:

     location ~ \.php$ {
    	root 			/xxx/xxx/;
    	......//其他配置
    }
    

    最后顺便说下,你还可以把index.php也省掉,配置是这样:

    location / {
    	root   /xxx/xxx/basic/web/;
    	index  index.php index.html index.htm;
    	if (!-e $request_filename) {
    		rewrite ^/index.php(.*)$ /index.php?s=$1 last;
    		rewrite ^(.*)$ /index.php?s=$1 last;
    		break;
    	}
    }
    

    那么你访问就是 www.kinstu.pw/?r=控制器/操作,这样来访问。

  • 回答于 2016-10-21 15:55 举报

    yii 的配置也要开启把

    'urlManager' => [

            'enablePrettyUrl' => true,
            'enableStrictParsing' => false,
            'showScriptName' => false,
            'rules' => [
            ],
        ],
    
  • 回答于 2016-11-10 11:42 举报

    location / {

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

    }

    在配置文件中改一下就可以了

您需要登录后才可以回答。登录 | 立即注册
siclgong
等待激活

siclgong

注册时间:2016-10-31
最后登录:1970-01-01
在线时长:0小时0分
  • 粉丝0
  • 金钱5
  • 威望0
  • 积分5

热门问题