Eduard Zintz | 08.06.2005 23:11 | RegEx - Suchmaschinenfreundliche Links? Hallo,
ein kleines Problem mit dem gestalten suchmaschinenfreundlicher Links. PHP-Code: <?php error_reporting(E_ALL); echo '<pre>'; $basehref = 'http://127.0.0.1/';
## Funktioniert #$hreflink = '<a href="' . $basehref . 'index.php?module=FOO&sid=md51864xg39123">Linkname</a>';
## Funktioniert #$hreflink = '<a href="' . $basehref . 'index.php?module=FOO&action=BAR&sid=md51864xg39123">Linkname</a>';
## Funktioniert nicht #$hreflink = '<a href="' . $basehref . 'index.php?module=FOO&action=BAR&newsid=89&sid=md51864xg39123">Linkname</a>'; ## Funktioniert nicht #$hreflink = '<a href="' . $basehref . 'index.php?module=FOO&action=BAR&contentid=57&sid=md51864xg39123">Linkname</a>';
$endlink = preg_replace('#index.php\?module=([\w].*?)&(?(?=action=)action=([\w].*?)&)(?(?=id=).*?id=([\d].*?)&)sid=([\w].*?)"#i', '$1/$2,$3.html?$4', $hreflink);
echo htmlspecialchars($endlink); echo '</pre>'; ?>
Das Problem ist, es wird ein bisschen anders replaced als gedacht. Das ganze hat ein Problem mit *id im Link.
Ich bin für jede Hilfe dankbar! |