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 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用