【问题标题】:Yii URL Rules RewriteYii URL 规则重写
【发布时间】:2016-11-01 16:06:24
【问题描述】:

我在main.phpurlManagerrules 下有以下URL 规则:

the-urly-bird => blog/content/index,

此页面 (http://www.accesstheflock.io/the-urly-bird) 有 10 页内容。我希望每个页面都有自己的URL,例如:http://www.accesstheflock.io/the-urly-bird/page/2

每个页面的路径是:?r=blog/content/index&Content_page=2

请为main.php 提供URL 规则以使这项工作正常进行。这是非常感谢的。谢谢。

【问题讨论】:

  • 在你的控制器中添加这个 $dataProvider=new CActiveDataProvider('Blog',array( 'pagination'=>array( 'pageVar'=>'page' ) ));
  • 谢谢。我试过这个。正如您在link 上看到的那样,它不起作用。 urlManager 规则会覆盖它。但是,在 localhost 上,它可以在 URL 中显示页面变量。谢谢你。请在 urlManager 中有规则。
  • 我能够编写有效的 URL 规则并在单击事件处理程序上添加一个 jQuery 以重定向到分页的正确 url。 'the-urly-bird/page/'=>'blog/content/index', 'the-urly-bird' => 'blog/content/index', $('li.page a ').on('click', function() { //重定向 window.location.href = $(this).attr('href'); return false; });

标签: url yii


【解决方案1】:

我能够编写有效的 URL 规则并在单击事件处理程序上添加一个 jQuery,以重定向到正确的分页 URL。

main.php

'the-urly-bird/page/<page:\d+>'=>'blog/content/index', 
'the-urly-bird' => 'blog/content/index', 

查看

$('li.page a').on('click', function() { //Redirects 
  window.location.href = $(this).attr('href'); 
  return false; 
}); –

【讨论】:

    猜你喜欢
    • 2018-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-27
    相关资源
    最近更新 更多