Seite 1 von 1

Mod_rewrite für Sitemap

Verfasst: 20.07.2005 15:34
von tiger87
Wie kann ich den Link viewtopic.php?t=".$topic['topic_id'] in den passenden short url link umwandeln?

Habe folgende Sitemap:

Code: Alles auswählen

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

/***************************************************************************
* Save this file as:   sitemap.php (or anything you like)
* Version:      Friday, Oct 4, 2002
* Email:      angus@phphacks.com
* Purpose of hack:   Basically generates a list of topics and
*      displays them with link to the topic. Goal
*      is to provide search engines like Google
*      with a static page of links to dynamic pages
*      You should link to this page from your sites
*      home page somewhere.
* Demo:      http://www.aussiecelebs.com/forums/site_map.php
* Tested on:   phpBB 2.01, 2.02
*
***************************************************************************/

/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
?>
<html>
<head>
<meta http-equiv="content-language" content="de">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Forum :: Sitemap</title>
<meta name="keywords" content="...">
<meta name="description" content="...">
</head>
<?php

echo "<h3>Alle Forum Beiträge</h3>";

$sql = "SELECT t.topic_id FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . FORUMS_TABLE . " AS f
    WHERE
        t.forum_id = f.forum_id AND f.auth_view = " . AUTH_ALL . " AND p.topic_id = t.topic_id AND p.post_id = t.topic_last_post_id ORDER BY p.post_time DESC";

$topicscount_query = $db->sql_query($sql);
$row_count = $db->sql_numrows($topicscount_query);
$max_count = $row_count/100;

if($HTTP_GET_VARS[next]>0 && $HTTP_GET_VARS[next]<=$max_count) {
    $next = $HTTP_GET_VARS[next];
}else {
    $next=0;
}


// SQL statement to fetch active topics of public forums
$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id
    FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . FORUMS_TABLE . " AS f
    WHERE
        t.forum_id = f.forum_id
            AND f.auth_view = " . AUTH_ALL . "
            AND p.topic_id = t.topic_id
            AND p.post_id = t.topic_last_post_id
    ORDER BY p.post_time DESC  LIMIT ".($next*100).",100";
$topics_query = $db->sql_query($sql);

if ( !$topics_query )
{
    message_die(GENERAL_ERROR, "Could not query list of active topics", "", __LINE__, __FILE__, $sql);
}
else if ( !$db->sql_numrows($topics_query) )
{
    message_die(GENERAL_MESSAGE, $lang['No_match']);
}
else
{
    while ($topic = $db->sql_fetchrow($topics_query))
    {
        echo "<a href='" . append_sid("viewtopic.php?t=".$topic['topic_id'])."'>".$topic["topic_title"]."</a><br>\n";
    }
}



echo "
<BR><BR>
[
";

for($ii=0; $ii<$max_count; $ii++) {
    if($ii+1<$max_count) {
        if($ii==$next) {
            echo("<A>&nbsp;".($ii+1)."&nbsp;|</A>");         
        }else{
            echo("<A HREF='" . append_sid("sitemap".($ii)).".html'>&nbsp;".($ii+1)."&nbsp;|</A>");
        }
    }else{
        if($ii==$next) {
            echo("<A>&nbsp;".($ii+1)."&nbsp;</A>");         
        }else{
            echo("<A HREF='" . append_sid("sitemap".($ii)).".html'>&nbsp;".($ii+1)."&nbsp;</A>");
        }
    }    
}

echo "
]
</body>
</html>
";
?>

Verfasst: 20.07.2005 15:46
von FatFreddy
Ich weiß nicht, nach welchem Muster Du die Short-Urls schreiben läßt, aber vom Prinzip funktioniert es wie folgt.

suche:

Code: Alles auswählen

        echo "<a href='" . append_sid("viewtopic.php?t=".$topic['topic_id'])."'>".$topic["topic_title"]."</a><br>\n"; 
ersetze durch:

Code: Alles auswählen

        echo "<a href='" . append_sid("about".$topic['topic_id']).".html'>".$topic["topic_title"]."</a><br>\n";

wobei Du das "about" durch das bei Dir gültige Prefix ersetzen mußt.

Gruß

FatFreddy

Verfasst: 20.07.2005 16:44
von tiger87
Noch ne Frage :)

hab in meiner mod rewrite folgendes stehen:

<files archive>
ForceType application/x-httpd-php
</files>

geht aber nicht :(

Kann man das irgendwie umschreiben? oder ist das was falsch?

Verfasst: 20.07.2005 19:45
von FatFreddy
tiger87 hat geschrieben:Noch ne Frage
Ist die erste denn beantwortet?

Dein neues Problem hat aber nichts mit der Sitemap zu tun, oder?

Ich vermute: phpbb Search engine Indexer

Sorry, gleiches Problem hat mich verleitet, 20 Topicseiten auf phpbb.com zu lesen. Ich hab das Ding nie zum Laufen gebracht. :evil:

Wäre schön, wenn jemand eine Lösung hätte.


FatFreddy

Verfasst: 22.07.2005 12:07
von tiger87
Jo danke erste Problem wurde gelöst aber das zweie leider nocht nicht :(