简体   繁体   English

带有漂亮URL的Yii分页

[英]Yii Paging with Pretty URLs

I have implemented pretty URLs that are working everywhere except paging. 我已经实现了漂亮的URL,除了分页之外,这些URL可以在所有地方使用。 I have been searching for the solutions including Paging with custom urls but it doesn't seem to work for me. 我一直在寻找解决方案,包括使用自定义网址进行分页,但它似乎对我不起作用。

I have this in my .htaccess 我的.htaccess中有这个

        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?/$1 [L]

Then I have these rules in my web.php file 然后我的web.php文件中有这些规则

      ''=>'site/index',
        'site/<title:\w+>'=>'site/index'
        'site/<title:\w+>/<page:\d+>'=>'site/index',
        '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
        '<controller:\w+>/<action:\w+>/<slug:\w+>' =>    
        '<controller>/<action>',
        '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
        'site/find/<slug>' => 'site/find',
        '/<slug>'=>'site/find',
        'defaultRoute'=>'site/index'

The paging is supposed to work on site index. 分页应该在站点索引上起作用。 What could I be missing? 我可能会缺少什么?

Your rules are in incorrect order - you must put more specific one (with page in pattern) before more generic one (without page in pattern): 您的规则顺序不正确-您必须在更通用的规则(模式中没有页面)之前放置更具体的规则(模式中带有页面):

'' => 'site/index',
'site/<title:\w+>/<page:\d+>' => 'site/index',
'site/<title:\w+>' => 'site/index',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>/<slug:\w+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'site/find/<slug>' => 'site/find',
'<slug>' => 'site/find',

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM