-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
37 lines (32 loc) · 942 Bytes
/
index.php
File metadata and controls
37 lines (32 loc) · 942 Bytes
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
<?php
/**
PHP redirection script
*/
$destination = "https://code-experience.fr/"; // IMPORTANT: $destination NEEDS to finish within /
$url = explode('/',$_SERVER['REQUEST_URI']);
foreach($url as $key => $part){
if($part==''){
unset($url[$key]);
}
}
$url = implode('/',$url);
// array of redirections
// $key = source / $value = destination
$urlCorrespondences = array();
// example = you can modify and add your redirections here
//$urlCorrespondences['/directory/index.php'] = "/index.php";
//$urlCorrespondences['/file.php'] = "/file2.php";
$urlCorrespondences['/'] = "";
foreach ($urlCorrespondences as $key=>$value) {
$position = strpos($url, $key);
if ($position === false) {
// Not found
$get = isset($get)?true:false;
$url = $url.($get?"?".http_build_query($_GET):"");
} else {
$url = $value;
}
} // end foreach
header("HTTP/1.1 301 Moved Permanently");
header('Location:'.$destination.$url);
exit();