关于yii2 urlManager配置无效

新手提问 · zhanghuid · 于 7年前 发布 · 8021 次阅读

关于yii2 urlManager配置无效

'urlManager' => [
        'class' => 'yii\web\UrlManager',
        'enablePrettyUrl' => true,
        'showScriptName' => false,
    ], 

按照官方配的,一设置就报

>The requested URL /demo/index.php was not found on this server.

我所做的努力是:

1 在这个帖子上查找yii2 urlManager 配置无效啊

2 及查看@forecho 在github上的rest的源码

结果发现:还是不行。希望懂的人,帮忙解决一下。
共收到 5 条回复 yii2 url美化
echo#17年前 0 个赞

/demo/index.php 是什么意思?项目首页的意思吗?你问题还是没描述清楚。

建议参考下 GetYii 的源码

顺便说一下 markdown 的格式不要乱用 不是代码就不要用代码块嘛

zhanghuid#27年前 0 个赞

我用的是basic的,不设置urlManger美化的话:http://localhost/demo/web/index.php?r=test/index可以运行

但是设置urlManger美化:

'urlManager' => [
        'class' => 'yii\web\UrlManager',
        'enablePrettyUrl' => true,
        'showScriptName' => false,
    ], 

执行:http://localhost/demo/web/test/index,就会报:

The requested URL /demo/index.php was not found on this server.

echo#37年前 0 个赞

@zhanghuid #2楼 服务器伪静态你没配置吧

zhanghuid#47年前 0 个赞

谢谢你的解答. 有配置,但是,把.htaccess放错位置了。应该放在web目录下,

qianyugang#56年前 0 个赞

因为你的apache 或者 nginx没有开启rewrite 模块

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册