]> git.mxchange.org Git - friendica.git/commitdiff
Avoid redirection loops at /fetch/ and /p/
authorMichael Vogel <icarus@dabo.de>
Thu, 30 Jun 2016 10:02:35 +0000 (12:02 +0200)
committerMichael Vogel <icarus@dabo.de>
Thu, 30 Jun 2016 10:02:35 +0000 (12:02 +0200)
mod/fetch.php
mod/p.php

index cfcd82bb31e04dd345bcff26b8b5aa230e88614d..1c73ad37185234328952834fa042bc0f237a8aa3 100644 (file)
@@ -27,11 +27,13 @@ function fetch_init($a){
                        $parts = parse_url($r[0]["author-link"]);
                        $host = $parts["scheme"]."://".$parts["host"];
 
-                       $location = $host."/fetch/".$a->argv[1]."/".urlencode($guid);
+                       if (normalise_link($host) != normalise_link(App::get_baseurl())) {
+                               $location = $host."/fetch/".$a->argv[1]."/".urlencode($guid);
 
-                       header("HTTP/1.1 301 Moved Permanently");
-                       header("Location:".$location);
-                       killme();
+                               header("HTTP/1.1 301 Moved Permanently");
+                               header("Location:".$location);
+                               killme();
+                       }
                }
 
                header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
index 899b51116dacb43aaf74ab47a37b8f4b9429e12e..8da044e9323916e742b2b1bb24404fefe854acdf 100644 (file)
--- a/mod/p.php
+++ b/mod/p.php
@@ -31,11 +31,13 @@ function p_init($a){
                        $parts = parse_url($r[0]["author-link"]);
                        $host = $parts["scheme"]."://".$parts["host"];
 
-                       $location = $host."/p/".urlencode($guid).".xml";
+                       if (normalise_link($host) != normalise_link(App::get_baseurl())) {
+                               $location = $host."/p/".urlencode($guid).".xml";
 
-                       header("HTTP/1.1 301 Moved Permanently");
-                       header("Location:".$location);
-                       killme();
+                               header("HTTP/1.1 301 Moved Permanently");
+                               header("Location:".$location);
+                               killme();
+                       }
                }
 
                header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));