我的 fecshop 项目,使用 Yii::$service->url->getUrl('/customer/account') 生成的url还是会带index.php

问题咨询 · tgy3300 · 于 4年前 发布 · 1712 次阅读

我的环境参照 http://www.fecshop.com/topic/398 教程配置了我的nginx,已经支持了无index.php访问,但是模板里使用

<?= Yii::$service->url->getUrl('/customer/account') ?>

生成的url,始终会有index.php,怎么才能去掉index.php,让生成出来的url没有index.php

共收到 4 条回复
Fecmall#14年前 0 个赞

你是fecshop,还是自己搭配的项目?

1.nginx的配置是,让没有index.php的url可以顺利访问,仅此而已,也就是一个url rewrite的过程

2.程序Yii::$service->url->getUrl('/customer/account')是yii2的url 字符串生成的过程

需要配置yii2组件

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

我记得是设置 showScriptNamefalse, 你试一下,fecshop默认都配置好了的。

3.如何还解决不了,自己debug一下代码找找原因

tgy3300#24年前 0 个赞

@Fecshop [#1楼](#comment1)

@common\config\main.php  代码如下:
return [
    'vendorPath' => dirname(dirname(__DIR__)).'/vendor',
    'components' => [
        'urlManager' => [
            'class'           => 'yii\web\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName'  => false,
            'rules'           => [],
        ],
        'assetManager' => [
            'forceCopy' => false,
        ],

    ],
];

我都配置好了,不是自己搭的,就是fecshop

tgy3300#34年前 0 个赞

明白了,是 @common\config\fecshop_local_services\Url.php 文件配置 showScriptName 为true了,

return [
    'url' => [
        'showScriptName'=> true,
         .....
    ],
];

这样的话,,@common\config\main.php 的配置就没用了

Fecmall#44年前 0 个赞

@tgy3300 #3楼

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