You can use preg_match to intercept the URL and fail to pass parameters.

Source: Internet
Author: User
If preg_match is used to intercept the URL and the parameter is not passed successfully, how can I modify it? I want to call the data of another website on one website, so that the two websites can call the same data, as they call data locally. For example, if I enter www.a.comx.php123456.rar on my website a and website B, I actually call www. B .com123456.rar (the actual file storage address) to use preg_match to intercept the website URL and fail to pass parameters, how can I modify the remedy?
I want to call the data of another website on one website, so that the two websites can call the same data

The same is called locally.

For example, my website a and website B

If I enter: http://www.a.com/x.php/123/456.rar
Actually called is: http://www. B .com/123/456.rar (real file storage address)
The downloaded file is still downloaded from www.a.com.

My x. php is like this:
Header ("content-Type: text/html; charset = Utf-8 ");
$ SERVER = $ _ SERVER ["REQUEST_URI"];
Preg_match ("/php \/([\ s \ S] +) \. rar/", $ SERVER, $ url );
$ Urlname = $ url [1];
$ Songurl = 'http: // www. B .com/'.w.urlname .'/';
Header ("location: $ songurl ");
?>

This code is used to pass 123 in the first Web site to the second Web site.
But the above code is not passed successfully:
I enter http://www.a.com/x.php/123/456.rarto display the second network region:

Http://www. B .com. "123" is not displayed on the website. could you tell me how to modify it so that the parameters "123" and "456" passed can be obtained for the second website.

Share:


------ Solution --------------------
1. first confirm
Whether the content in $ _ SERVER ["REQUEST_URI"] is x. php/123/456 .rar
2. the regular expression is actually changed
Preg_match ("/php \/([\ s \ S] + \. rar)/", $ SERVER, $ url );
$ Urlname = $ url [1];
$ Songurl = 'http: // www. B .com/'.w.urlname; // this way, you can piece together a link suffixed with rarat http://www. B .com/123/456.rar.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.