-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpt-redirect.php
48 lines (41 loc) · 1.3 KB
/
pt-redirect.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
43
44
45
46
47
48
<?php
/*
Template Name: Redirect Page (Permanent)
*/
the_post();
$soup_redirectTo = get_post_meta($post->ID, 'redirectTo', true);
$soup_parsed = parse_url($soup_redirectTo);
if (($soup_redirectTo) AND (($soup_parsed['scheme'] == 'http') OR ($soup_parsed['scheme'] == 'https'))) {
//echo "<!-- 1 -->";
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: " . $soup_redirectTo );
}
elseif (($soup_redirectTo)) {
//presume absolute url on this site
if (substr($soup_redirectTo,0,1) != '/') {
$soup_redirectTo = '/' . $soup_redirectTo;
}
$blogurl_parsed = parse_url(home_url());
$soup_redirectToPrefix = $blogurl_parsed['scheme'] . '://' . $blogurl_parsed['host'];
$soup_redirectTo = home_url() . $soup_redirectTo;
//echo "<!-- 2 $soup_redirectTo -->";
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: " . $soup_redirectTo );
/* ? >
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="<?php echo $soup_redirectTo; ?>">here</a>.</p>
</body></html>
< ? php */
}
else {
//just show the user the page content
$templates[] = "page.php";
if ('' == locate_template($templates, true)) {
load_template( get_theme_root() . '/default/page.php');
}
}
?>