15053971836 注册 / 登录

伪静态参数字母的写法

时间: 阅读:280
伪静态参数字母的写法

最佳回答

阳光下的阴霾

阳光下的阴霾

2023-01-16 05:42:22

 

 比如我现在在yii框架中访问名叫List控制器(Controller)的index动作(action)且参数为 big_class等于1 则为: 
http://www.test.com/index.PHP?r=list/index&big_class=1
,如果翻页的话会是
http://www.test.com/index.php?r=list/index&big_class=1&page=1
,2,3,4……

那么接下来我在main.php 中定义rewrite规则,在components大数组中加入

'urlManager' => array(

'urlFormat' => 'path',

'rules' => array(

'<controller:w+>/<action:w+>/<page:d+>' => '<controller>/<action>/<page>',

),

),

这样再次访问以上链接时就会变为:

http://www.test.com/list/index/big_class/1 且列表翻页后会是 http://www.test.com/list/index/big_class/1/page/1 http://www.test.com/list/index/big_class/1/page/2 ……

这样就达到了伪静态的效果,可以不出现?或者&符号等参数了

最新回答共有2条回答

  • 清风若雨
    回复
    2023-01-16 07:07:24

    首先要确定你的空间支不支持rewrite的,如果支持的话,就这样的写就可以了

    如果是多条,就按照这个格式

    <Files ~ "^.(htaccess|htpasswd)$">
    deny from all
    </Files>
    Redirect permanent www.abc.com/index.php?x=32 www.abc.com/x_32.html
    order deny,allow