// Freier Code, Verwendung auf eigene Verantwortung function seofriendlyDateiname($str) { // hier kann natürlich auch utf-8 eingetragen werden $str = mb_strtolower($str, 'windows-1252'); $str = str_replace(".", "-", $str); $str = str_replace("/", "-", $str); $str = str_replace(" & ", "-", $str); $str = str_replace(" ", "-", $str); $str = str_replace("%", "", $str); $str = str_replace("ä", "%E4", $str); $str = str_replace("ö", "%F6", $str); $str = str_replace("ü", "%FC", $str); $str = str_replace("ß", "ss", $str); $str = str_replace(" - ", "-", $str); $str = str_replace("--", "-", $str); $str = str_replace("--", "-", $str); $str = str_replace("--", "-", $str); $str = preg_replace('/[^a-z%0-9_-]/isU', '', $str); $str = str_replace("--", "-", $str); $str = addslashes(trim($str)); // In der Datenbank schauen, ob bereits ein solcher Eintrag vorhanden ist // falls noch nicht vorhanden, musst Du noch die DB-Verbindung aufbauen! $anfrage = mysql_query("SELECT id, titel FROM mein_linkverzeichnis WHERE permalink = '$str'"); $anzahl = mysql_num_rows($anfrage); if ($anzahl > 0) { // seofriendly-URL bereits vorhanden! $anfrage2 = mysql_query("SELECT id FROM mein_linkverzeichnis WHERE permalink LIKE '$str-%'"); $anzahl2 = mysql_num_rows($anfrage2); $str = $str."-".($anzahl2++); } return $str; }