I have a system that sends data to URL1. I want this system to send data to URL1 and URL2. I tried a normal redirect in cPanel but this only allows for redirection to one URL. What would be the easiest way to redirect the traffic sent by the system to one single URL (URL3) which in turn can then redirect to URL1, URL2 and how many ever other URLs I decide to add in the future?
Asked
Active
Viewed 159 times
1
-
So you want an index page with links? or you want to open many tabs? – funerr Mar 08 '13 at 12:08
-
I want whatever information is posted to URL3 (the new URL) to also get posted to URL1, URL2 and whatever other URLs I specify? – rockstardev Mar 08 '13 at 12:10
-
So you redirect to URL3 with some data and then URL3 sends the same data to URL1 and URL2? why do you need to redirect then? (ajax, iframe...) – funerr Mar 08 '13 at 12:14
-
Dont see it as a redirect in the conventional sense. There is a system that is POSTING data to URL3, which in turn must be posted to URL1 and URL2. Is this something that can be done with standard CNAME entry redirects, or must there be a PHP script with some logic that catches the data and reposts it? – rockstardev Mar 08 '13 at 12:22
1 Answers
0
I am not sure about the CNAME entry, maybe someone else will have a solution using it.
I would use php:
Flow:
URL3 gets data from POST, then sends the data to URL1 & URL2.
I am using the code from: How do I send a POST request with PHP? (PHP5)
function postData($url, $value){
$data = array('key' => $value);
$options = array('http' => array('method' => 'POST','content' => http_build_query($data)));
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
}
In URL3:
$data = $_POST['data'];
$urls = array('URL1', 'URL2');
foreach ($urls as $i) {
postData($i, $data);
}