Hallo,
ich handle hier die Interpration einer sinnhaften, seo freundlichen Url. Ich brauche aber Eure Kritik und Verbesserungsvorschläge. Der Code soll absolute seo - freundlich sein
ich handle hier die Interpration einer sinnhaften, seo freundlichen Url. Ich brauche aber Eure Kritik und Verbesserungsvorschläge. Der Code soll absolute seo - freundlich sein
PHP-Code:
public function f_get_id ($req_uri) { //sinnhafte Ordnerstrukturen
$this -> canonical = '';
$url = substr(str_replace(self::ROOT, '', $req_uri), 1);
$id = array_search($url, $GLOBALS['url'], true); //aus Liste von z.B. $GLOBALS['url'][4] = "mein/ordner"
if ($id == false AND isset($_GET['id'])) {
$id = $_GET['id'];
$sql = "SELECT id FROM ".self::PREFIX."sections WHERE id = '$id' AND public_status = '2';";
$result = $this->db->query($sql);
if($this->db->error != "")
die($this->db->error."_checkNode");
if ($result->num_rows == 0) {
$id = $this -> getDefaultId();
$this -> canonical = "<link rel=\"canonical\" href=\"https://".$_SERVER['SERVER_NAME']."\" />";
header("HTTP/1.0 404 Not Found");
} else {
$new_url = $GLOBALS['url'][$id];
$this -> canonical = "<link rel=\"canonical\" href=\"https://".$_SERVER['SERVER_NAME']."/".self::ROOT.$new_url."\" />";
}
} else if($req_uri == "/".self::ROOT."" OR $req_uri == "/index.php") {
$id = $this -> getDefaultId();
} else if ($id == false) {
$id = $this -> getDefaultId();
$this -> canonical = "<link rel=\"canonical\" href=\"https://".$_SERVER['SERVER_NAME']."\" />";
header("HTTP/1.0 404 Not Found");
}
$sql = "SELECT id FROM ".self::PREFIX."sections WHERE id = '$id' AND public_status = '2';";
$result = $this->db->query($sql);
if($this->db->error != "")
die($this->db->error."_checkNode");
if ($result->num_rows == 0) {
$id = $this -> getDefaultId();
$this -> canonical = "<link rel=\"canonical\" href=\"http://".$_SERVER['SERVER_NAME']."\" />";
header("HTTP/1.0 404 Not Found");
}
return $id;
}
Kommentar