dreamlife2014 2014-08-09 11:04
浏览 26
已采纳

在main.php yii中的URL设置中加密参数?

Here problem is with encrypt code in the url,

My url is this and encrypt code is at the last:

http://localhost/php_pro_106/reload/ByCustomer/mJYwIzoaIGe0R8lAVCqPhG%2Fg0jJFWjiWWdPnkq5VDlY%3D

In main.php Url settings:

'urlManager'=>array(
     'urlFormat'=>'path',
     'showScriptName' => false,
      'caseSensitive'=>false,
        'rules'=>array(
            'giftcard/<id:\w+>'=>'giftcard/index',
            'reload/ByCustomer/<giftcode:\w+>'=>'reload/ByCustomer',

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

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

           ),
    ),

my action is in reload controller:

public function actionByCustomer()
  {

    echo "test";
    print_r($_GET);
    }

I am getting:

The requested URL     /localhost/reload/ByCustomer/mJYwIzoaIGe0R8lAVCqPhG/g0jJFWjiWWdPnkq5VDlY= was    
not found on this server.

Actually problem is with ByCustomer/mJYwIzoaIGe0R8lAVCqPhG%2Fg0jJFWjiWWdPnkq5VDlY%3D as it is encrypt.What Should I do to make it work?

  • 写回答

2条回答 默认 最新

  • dsm0688 2014-08-11 17:30
    关注

    I got the solution of it,For that I have to change my encode and decode method:

    The problem was due to some characters which are there in encoded Url.So, I have to replace these characters.

    In main.php Url Manager will be like:

      'reload/ByCustomer/<giftcode>'=>'reload/ByCustomer',
    

    The apache has problem with %2F in URL, it will always reply with 404, php script is not executed.

    EDIT:

    There's a solution, but it requires you can edit apache configuration file for your virtual host at least (I didn't have that at that time). Then you have to add AllowEncodedSlashes On inside your <VirtualHost>. Or you can also set it globally.

    If you dont want to do this.

    These links Help me:

    Stack over flow Solution1

    Stack over flow solution2

    google group

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?