kleines problem bei biz directory

Wie wir alle wissen (sollten) ändert mod_rewrite keine Links im Script. Damit auch die Links auf Deiner Page auf die neuen "Rewrited URLs" zeigen bedarf es der Anpassung im Code. Fragen und Probleme rund um's Coding werden hier diskutiert.

Moderator: Super-Mod

kleines problem bei biz directory

Beitragvon kai1083 » 05.05.2005 23:41

hi leute,

ich h0offe jemand kann mir weiter helfen und zwar habe ich nach euren tut mod_rewrite beim biz angewendet, funktioniert auch ganz gut. Aber leider hab ich da irgendwo einen kleinen fehler und zwar wenn ich in einer unterkategorie bin und dann auf die kategorie drücke die vor der kategorie war kommt eine falsche url und zwar diese :2webkatalog also das html fehlt da am ende.

meine .htaccess
Code: Alles auswählen
DirectoryIndex  index.php
RewriteEngine On

RewriteRule index.html$ /erotiksuchmaschine/index.php [L]
RewriteRule ^([0-9]+)-webkatalog.html$ /erotiksuchmaschine/index.php?c=$1 [L]
RewriteRule ^([0-9]+)-webkatalog.html$ /erotiksuchmaschine/index.php?s=$1 [L]
RewriteRule ^([0-9]+)-([0-9]+)-webkatalog.html$ /erotiksuchmaschine/index.php?c=$1&s=$2 [L]
RewriteRule ^([0-9]+)-link-eintragen.html$ /erotiksuchmaschine/add_url.php?c=$1 [L]


meine index.php
Code: Alles auswählen
<?
require_once("config.php");
require_once("include.php");
require_once("template_index.php");
$c *= 1;
if ($c == 0) $c = 1;
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
mysql_select_db($mysql_database, $bd);
$sql = mysql_query("SELECT name, title, description, pages, ref FROM {$prefix}categories WHERE id = $c");
$current_category = mysql_fetch_array($sql, MYSQL_ASSOC);
if (($c > 1) & !$current_category["name"]){
   mysql_close();
   header("Location: {$dir}");
   exit();
};
if (!$current_category["name"]) $current_category["name"] = "Free PHP Directory Script";
if (!$current_category["description"]) $current_category["description"] = $current_category["name"]." ".$current_category["title"];
$replace = array("[CATEGORY_NAME]" => $current_category["name"], "[CATEGORY_TITLE]" => $current_category["title"], "[CATEGORY_DESCRIPTION]" => $current_category["description"]);
echo strtr($TEMPLATE["HEADING"],$replace);
flush();
$last_category = false;
$ref = $c;
while(!$last_category){
   $n_parent_categories += 1;
   $sql = mysql_query("SELECT id, name, ref FROM {$prefix}categories WHERE id = $ref");
   $parent_categories[$n_parent_categories-1] = mysql_fetch_array($sql, MYSQL_ASSOC);
   if ($parent_categories[$n_parent_categories-1]["ref"] == 0){
      $last_category = true;
   }else{
      $ref = $parent_categories[$n_parent_categories-1]["ref"];
   };
};
echo $TEMPLATE["PATH"]["HEADING"];
for ($x = $n_parent_categories-1; $x >= 0; $x--){
   if ($x != $n_parent_categories-1) echo $TEMPLATE["PATH"]["SEPARATOR"];
   if ($x == 0){
      $replace = array("[CATEGORY_NAME]" => $parent_categories[$x]["name"]);
      echo strtr($TEMPLATE["PATH"]["CURRENT_CATEGORY"],$replace);
   }else{
      if ($parent_categories[$x]["id"] > 1){
         $category_url = $dir.$parent_categories[$x]["id"].'webkatalog';
      }else{
         $category_url = $dir;
      };
      $replace = array("[CATEGORY_NAME]" => $parent_categories[$x]["name"], "[CATEGORY_URL]" => $category_url);
      echo strtr($TEMPLATE["PATH"]["CATEGORY"],$replace);
   };
};
echo $TEMPLATE["PATH"]["FOOTER"];
flush();
$sql = mysql_query("SELECT {$prefix}categories.id, {$prefix}categories.name FROM {$prefix}categories LEFT JOIN {$prefix}pages ON {$prefix}pages.category = {$prefix}categories.id AND {$prefix}pages.accepted = 'y' WHERE ref = $c GROUP BY {$prefix}categories.id ORDER BY {$prefix}categories.name");
$n_subcategories = mysql_num_rows($sql);
for ($x = 0; $x < $n_subcategories; $x++){
   $subcategories[$x] = mysql_fetch_array($sql, MYSQL_ASSOC);
};
if ($n_subcategories > 0){
   $replace = array("[NUMBER_CATEGORIES]" => $n_subcategories, "[CATEGORY_NAME]" => $current_category["name"]);
   echo strtr($TEMPLATE["SUBCATEGORIES"]["HEADING"],$replace);
   echo $TEMPLATE["SUBCATEGORIES"]["BEFORE_COLUMNS"];
   for ($x = 0; $x < ceil($n_subcategories/2); $x++){
      $replace = array("[CATEGORY_NAME]" => $subcategories[$x]["name"], "[CATEGORY_URL]" => $dir.$subcategories[$x]["id"].'-webkatalog.html');
      echo strtr($TEMPLATE["SUBCATEGORIES"]["CATEGORY"],$replace);
   };
   echo $TEMPLATE["SUBCATEGORIES"]["BETWEEN_COLUMNS"];
   for ($x = ceil($n_subcategories/2); $x < $n_subcategories; $x++){
      $replace = array("[CATEGORY_NAME]" => $subcategories[$x]["name"], "[CATEGORY_URL]" => $dir.$subcategories[$x]["id"].'-webkatalog.html');
      echo strtr($TEMPLATE["SUBCATEGORIES"]["CATEGORY"],$replace);
   };
   echo $TEMPLATE["SUBCATEGORIES"]["AFTER_COLUMNS"];
   echo $TEMPLATE["SUBCATEGORIES"]["FOOTER"];
}else{
   $replace = array("[CATEGORY_NAME]" => $current_category["name"]);
   echo strtr($TEMPLATE["SUBCATEGORIES"]["NO_CATEGORIES"],$replace);
};
if ($current_category["pages"] == "y"){
   $replace = array("[CATEGORY_NAME]" => $current_category["name"], "[SUBMISSION_URL]" => $dir.$c.'-link-eintragen.html');
   echo strtr($TEMPLATE["SUBMISSION_LINK"],$replace);
   flush();
   if ($s == 0) $s = 1;
   $n = 10;
   $sql = mysql_query("SELECT COUNT(*) AS total_pages FROM {$prefix}pages WHERE category = $c AND accepted = 'y'");
   $total_pages = mysql_result($sql,0,"total_pages");
   if ($total_pages > 0){
      $sql = mysql_query("SELECT id, url, title, description FROM {$prefix}pages WHERE category = $c AND accepted = 'y' ORDER BY title LIMIT ".($s-1).",$n");
      $n_pages = mysql_num_rows($sql);
      for ($x = 0; $x < $n_pages; $x++){
         $pages[$x] = mysql_fetch_array($sql, MYSQL_ASSOC);
      };
   };
   if ($show_additional_results){
      flush();
      require_once("include_ppc.php");
      $ppc_results = ppc_results($current_category["name"]);
      if ($s > $total_pages){
         $s2 = $s - $total_pages;
      }else{
         $s2 = 1;
      };
      $e2 = $s2 + min($s + $n - $total_pages - 1, count($ppc_results) - $s2 + 1);
      $total_pages += count($ppc_results);
      for ($x = $s2; $x < $e2; $x++){
         $n_pages += 1;
         $e += 1;
         $pages[$n_pages-1] = $ppc_results[$x];
      };
   };
   $e = min($s + $n - 1, $s + $n_pages - 1);
   if ($n_pages > 0){
      $replace = array("[STARTING_PAGE_NUMBER]" => $s, "[ENDING_PAGE_NUMBER]" => $e, "[TOTAL_PAGES]" => $total_pages, "[CATEGORY_NAME]" => $current_category["name"]);
      echo strtr($TEMPLATE["PAGES"]["HEADING"],$replace);
      for ($x = 0; $x < $n_pages; $x++){
         if ($pages[$x]["domain"]){
            $replace = array("[PAGE_NUMBER]" => $x, "[PAGE_TITLE]" => $pages[$x]["title"], "[PAGE_DESCRIPTION]" => $pages[$x]["description"], "[PAGE_URL]" => $pages[$x]["url"], "[PAGE_DOMAIN]" => $pages[$x]["domain"]);
            echo strtr($TEMPLATE["PAGES"]["FEED_PAGE"],$replace);
         }else{
            $replace = array("[PAGE_NUMBER]" => $x, "[PAGE_TITLE]" => $pages[$x]["title"], "[PAGE_DESCRIPTION]" => $pages[$x]["description"], "[PAGE_URL]" => $pages[$x]["url"], "[PAGE_DOMAIN]" => $pages[$x]["domain"]);
            echo strtr($TEMPLATE["PAGES"]["PAGE"],$replace);
         };
      };
      if ($s != 1 || $e != $total_pages){
         function pagination($s){
            global $c, $dir;
            if ($c != 1) { $query = "$c-webkatalog.html"; };
  if (($c != 1) & $s != 1){
    $query = "$c-$s-webkatalog.html";
  }elseif ($s != 1){
    $query = "$c-$s-webkatalog.html";
};
            return $dir.$query;
         };
         echo $TEMPLATE["PAGES"]["PAGINATION"]["HEADING"];
         if ($s != 1){
            $previous = $s - $n;
            $replace = array("[PAGINATION_URL]" => pagination($previous));
            echo strtr($TEMPLATE["PAGES"]["PAGINATION"]["PREVIOUS"],$replace);
         };
         for ($x = 1; $x <= ceil($total_pages/$n); $x++){
            $current = ($x-1) * $n + 1;
            if ($current == $s){
               $replace = array("[PAGINATION_NUMBER]" => $x);
               echo strtr($TEMPLATE["PAGES"]["PAGINATION"]["CURRENT_NUMBER"],$replace);
            }else{
               $replace = array("[PAGINATION_NUMBER]" => $x, "[PAGINATION_URL]" => pagination($current));
               echo strtr($TEMPLATE["PAGES"]["PAGINATION"]["NUMBER"],$replace);
            };
         };
         if ($e < $total_pages){
            $next = $s + $n;
            $replace = array("[PAGINATION_URL]" => pagination($next));
            echo strtr($TEMPLATE["PAGES"]["PAGINATION"]["NEXT"],$replace);
         };
         echo $TEMPLATE["PAGES"]["PAGINATION"]["FOOTER"];
      };
      echo $TEMPLATE["PAGES"]["FOOTER"];
   }else{
      $replace = array("[CATEGORY_NAME]" => $current_category["name"]);
      echo strtr($TEMPLATE["PAGES"]["NO_PAGES"],$replace);
   };
};
echo $TEMPLATE["FOOTER"];
?>

danke schonmal im vorraus

liebe grüße kai
kai1083
.
.
 
Beiträge: 7
Registriert: 23.03.2005 16:35

Beitragvon kai1083 » 06.05.2005 10:18

habs selber schon gefunden
kai1083
.
.
 
Beiträge: 7
Registriert: 23.03.2005 16:35


Zurück zu Programmierung & Scriptanpassung für mod_rewrite

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 0 Gäste