0

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?

unknownbits
  • 2,855
  • 10
  • 41
  • 81
  • 1
    Please post your UrlManager rules here, and the controller action that you want to run. Then reply to this comment to say you have updated the question. – Samuel Liew Aug 10 '14 at 02:55

2 Answers2

2

In your byCustomer rule the giftcodes regex matches on words. But that uri part mJYwIzoaIGe0R8lAVCqPhG%2Fg0jJFWjiWWdPnkq5VDlY%3D is not a word since it contains chars like %. It looks like an url encoded string, the %2f would be a / and the %3d a =. However all these chars a not in a word.

Try this rule:

'reload/ByCustomer/<giftcode:.+>'=>'reload/ByCustomer',

It matches any character after reload/ByCustomer/ which looks okay for your purpose.

chris---
  • 1,536
  • 1
  • 13
  • 14
0

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

Community
  • 1
  • 1
unknownbits
  • 2,855
  • 10
  • 41
  • 81