doutuichan2681 2014-07-28 20:13
浏览 95

Yii框架路由不起作用

I have problem with Yii routing system and it does not work for me.
I use the default forms of the yii in my app like:
http://example.com/site/login

but when a user click on submit button and it takes more than few seconds to proceed the data, the routing system will fail and the above address will change to:
http://site/login (!!!)
I can't understand why it happens.

this is my URLManager:

'urlManager'    => array(
    'urlFormat'      => 'path',
    'rules'          => array(
        '<controller:\w+>/<id:\d+>'                       => '<controller>/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>'          => '<controller>/<action>',
        '<controller:\w+>/<action:\w+>'                   => '<controller>/<action>',
        'moderator'                                       => 'moderator/Post',
        'admin'                                           => 'admin/main',
        'index/'                                          => 'site/index',
        'profile/show/<username>'                         => 'profile/show',
        'profile/list/<sorting:[a-zA-Z0-9-]+>/<page:\d+>' => 'profile/list',
        'admin/contact/page/<page:\d+>'                 => 'admin/contact',
        'admin/contact/view/<id:\d+>'                   => 'admin/contact/view',
    ),
    'showScriptName' => false,
),

and my .htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine On
</IfModule>


# Unless an explicit file or directory exists, redirect all request to Yii entry script
<IfModule mod_rewrite.c>
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . index.php
</IfModule>
  • 写回答

2条回答 默认 最新

  • dongqian1028 2014-07-28 20:39
    关注

    Move these three default rules to the end of the rules array:

    '<controller:\w+>/<id:\d+>'                       => '<controller>/view',
    '<controller:\w+>/<action:\w+>/<id:\d+>'          => '<controller>/<action>',
    '<controller:\w+>/<action:\w+>'                   => '<controller>/<action>',
    

    Also, please post the code for site/login action so I can help you further.

    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题