-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpantheon-redirects.php
33 lines (31 loc) · 1.47 KB
/
pantheon-redirects.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
<?php
/**
* The included arrays work in two different ways.
*
* @param $one_to_ones is written with the request URI as the key
* and the complete URL as the value. These must be written from
* specific to generic since the loop does a generic check using
* the `strpos` function; therefore, URIs that are more generic
* should be written after the more specific ones matching a
* similar path.
* @param $regex_rules is written using regular expressions with
* the regex as the key and the full URL with regex replacements
* as the value. If the regex value is matched, the specified
* replacement will be will be redirected.
* @internal note that the request URI starts with a forward slash
* @internal note that regular expressions in PHP start and end with
* forward slashes, so forward slashes need to be escaped. Similarly
* other characters that are regex pattern delimiters must be escaped.
* @see http://php.net/manual/en/regexp.reference.delimiters.php
*/
// one-to-one redirects
$one_to_ones = array(
"/path/to/page" => "https://www.example.org/page/"
);
// regex-based redirects
$regex_rules = array(
"/\/festival\/(\d+)\/(\d+)\/(.*).php$/" => "https://www.example.org/events/$3",
"/\/your-visit\/your-visit\/(.*).php$/" => "https://www.example.org/visit/$1",
"/\/about\/(.*).php$/" => "https://www.example.org/about/$1",
"/\/education\/school\/programs\/(.*).php$/" => "https://www.example.org/school/$1"
);