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.