-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomeRedirect.php
43 lines (38 loc) · 1000 Bytes
/
homeRedirect.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
$path = "";
$url = "http://my-server.com";
$url2 = "http://192.168.1.11";
if (isset($_REQUEST['p'])) {
$path = "/{$_REQUEST['p']}/";
unset($_REQUEST['p']);
}
$queryParams = http_build_query($_REQUEST);
$queryParams = ($queryParams) ? "?{$queryParams}" : "";
$paramsUrl = "{$url}{$path}{$queryParams}";
$paramsUrl2 = "{$url2}{$path}{$queryParams}";
?>
<!doctype html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript">
var url = '<?= $url ?>';
var url2 = '<?= $url2 ?>';
$.ajax({
url: url2,
cache: false,
crossDomain: true,
dataType: "script",
timeout: 300,
context: document.body,
success: function(data, textStatus, jqxhr) {
window.location = '<?= $paramsUrl2 ?>'
},
error: function(jqxhr, textStatus, errorThrown) {
window.location = '<?= $paramsUrl ?>'
}
})
</script>
</head>
</html>