【问题标题】:how to completely hide the url in yii2如何在yii2中完全隐藏url
【发布时间】:2014-09-18 20:54:08
【问题描述】:

使用 yii2,我正在创建一个页面来显示一个类别的结果,并停留在 url 规则中。

现在,我有一个名称类似于 training-centers 的类别,该类别的 id 是 5 并且需要通过列表操作将此 categoryid 传递给教育控制器。

我需要在yii2中写一个规则,

'training-centers' => 'education/list' //how to pass the id

如何编写这种类型的规则,其中 id 或其他标识符在 url 中不可用?

我们可以/如何使用 .htacess 来做到这一点?

启用漂亮的网址后,它不起作用

RewriteRule training-centers index.php?r=education-list&id=5

一行中,在 url 中无法识别 controller/action/id 的 yii 中如何写 url?

【问题讨论】:

    标签: .htaccess url-rewriting yii2


    【解决方案1】:

    试试这个代码:

    'urlManager' => [
        'rules' => [         
            'training-centers' => 'index.php?r=education-list&id=5'
         ]
     ],
    

    或在 .htaccess 中

    RewriteRule ^training-centers$ /education/list/?id=5
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-23
      • 2015-08-01
      • 1970-01-01
      • 2020-02-23
      • 2019-07-22
      • 1970-01-01
      • 2011-08-16
      相关资源
      最近更新 更多