forked from platformsh/platformsh-docs
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
18 lines (17 loc) · 783 Bytes
/
index.php
File metadata and controls
18 lines (17 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
# Mapping of old URLs as key, and new URLs as values.
$url_mapping = array(
'/web-ui/configure-environment' => '/overview/web-ui/configure-environment.html',
'/web-ui/configure-project' => '/overview/web-ui/configure-project.html'
);
# Load HTML files until Platform.sh supports directory indexes.
$path = parse_url($_SERVER['REQUEST_URI']);
$path = ltrim(rtrim($path["path"], '/'), '.'); //trim trailing slash and prefix dots
$index = realpath(getcwd() .$path ."/index.html");
if (substr($index, 0, strlen(realpath(getcwd()))) === realpath(getcwd()) && file_exists($index)){
header("Cache-Control: public, max-age=300");
readfile($index);
} else {
$location = array_key_exists($path, $url_mapping) ? $url_mapping[$path] : '/';
header('Location: ' . $location);
}