luoxuan 2015-11-27 15:40:18 3868次浏览 5条回复 0 0 0

把这段释放出来后,报错

'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
    ],
],

地址是变了:http://localhost:3721/yii2test/frontend/web/site/about

但是报了下面的错误。

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404

localhost
Apache/2.4.4 (Win32) OpenSSL/1.0.1e PHP/5.5.1
  • 回复于 2015-11-29 09:51 举报

    本站搜索一下 urlManager 好多的

  • 回复于 2015-11-30 18:34 举报

    配置文件应该没有问题

    'components' => [
        'urlManager'=>[
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'asdasd',
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
    ]
    
  • 回复于 2015-12-01 15:15 举报

    伪静态规则

  • 回复于 2015-12-03 15:56 举报
    'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'suffix' => ".html",
        'rules' => [
            ''=>'site/index',
            ['class' => 'yii\rest\UrlRule', 'controller' => ['site/index', 'memchant/index','mobile/custom','mobile/tiao','mobile/down','mobile/sure']],
        ]
    ]
    

    这是我们配的一个 URL 伪静态规则

  • 回复于 2015-12-10 16:16 举报

    总算解决了,需要在web下面增加一个 .htaccess 文件,之前自己给这个文件加了个文件名

您需要登录后才可以回复。登录 | 立即注册