URL contain % ,/ would be a / and the = a = In yii

2019-09-15 23:19发布

My url in yii is:

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

what should I have to do in url manager to get this,My current rule is:

'<controller:\w+>/ByCustomer/<giftcode>'=>'<controller>/ByCustomer',

Actually problem is that I get :

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

It is due to %3D %2F in the URL.What I have to do to make it work fine?

2条回答
我想做一个坏孩纸
2楼-- · 2019-09-15 23:49

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

function base64_url_encode($input) {
 return strtr(base64_encode($input), '+/=', '-_,');
}

function base64_url_decode($input) {
 return base64_decode(strtr($input, '-_,', '+/='));
} 

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

These links Help me:

Stackoverflow

and

google Group

查看更多
虎瘦雄心在
3楼-- · 2019-09-15 23:52

I know apache has problem with %2F in URL, it will always reply with 404, php script is not executed. I never found a way around it. But that was some years ago.

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 globaly.

查看更多
登录 后发表回答