Home >Backend Development >PHP Tutorial >How to receive the value passed by alipay after hiding the entry file in url in ThinkPHP, _PHP tutorial
The example in this article describes the method of receiving the value from alipay after hiding the entry file in the url in ThinkPHP. Share it with everyone for your reference. The specific method is as follows:
Nowadays, the needs of company projects are ever-changing. The project uses Thinkphp2.0, and the URL_MODEL=2 set in conf.php is for compatibility with .htaccess and hiding index.php, but when using some third-party interfaces (such as Alipay or MSN open platform), the parameters they return often contain a ? number, and when URL_MODEL=2, TP will automatically convert URLs containing ?.
Before conversion: http://www.xxx.com/index.php/alipay/callback/?is_success/T/sign_type/MD5/notify_id/RqPnCoPT3K9/vwbh3I
After conversion: http://www.xxx.com/alipay/callback/is_success/T/sign_type/MD5/notify_id/RqPnCoPT3K9/vwbh3I
The converted URL will be inaccessible, but the pre-converted URL is accessible. At this time, you need to temporarily target the alipay controller, URL_MODEL=1, but in this controller C('URL_MODEL',1) is It's useless, because TP will directly issue 404 when entering the entry file App::run().
I thought of many ways, first I modified its configuration file Conf.php, and found that a cache file ~app.php would be generated, so I had to delete this cache file according to the situation, so I modified the index.php entry file ( In fact, it can be placed before any App::run(), you can encapsulate it yourself).
PHP example code:
PHP example source code:
I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.