htaccess问题。一个规则有效,其他不是

我有htaccess重写问题。我正在创建一个简单的论坛。

FCategory工作规则和重写URL。但是ftopic的规则并没有。(对象未找到错误404)。可能是什么问题呢?

PHP代码:

<?php
require "includes/header.php";

// Forum topic list.
if (isset($_GET["fcategory"])) {
    $category_id = $_GET["fcategory"];
  foreach($handler->query("SELECT * FROM forum_topics WHERE category_id = '$category_id' ORDER BY id DESC") as $row) {
        echo "<div class='forum_topic_title'><h1><a href='".$host."/ftopic/".$row['id']."/".$row['topic_title_seo']."'>".$row['topic_title']."</a></h1></div>";
  }

}
// Forum post content.
else if (isset($_GET["ftopic"])) {
  $topic_id = $_GET["ftopic"];
  foreach($handler->query("SELECT * FROM forum_posts WHERE topic_id = '$topic_id' ORDER BY id DESC") as $row) {
    echo "<div class='forum_post_content'>".$row['post_content']."</div>";
  }
}
// Forum category list.
else {
  foreach($handler->query("SELECT * FROM forum_categories ORDER BY id DESC") as $row) {
    echo "<div class='forum_category_title'><h1><a href='".$host."/fcategory/".$row['id']."/".$row['category_title_seo']."'>".$row['category_title']."</a></h1></div>";
    echo "<div class='forum_category_description'>".$row['category_description']."</div>";
  }
}

require "includes/footer.php";
?>

和Htaccess代码:

# Turn Rewrite Engine On
# NC makes the rule non case sesnitive
# L makes this the last rule that this specific condition will match
# Rewrite for custom.php?article=xxxxx

RewriteEngine on

# Rewrite for index.php
RewriteRule ^index index.php [NC,L]
RewriteRule ^article/([0-9]+) index.php?article=$1 [NC,L]


# Rewrite for forum.php
RewriteRule ^forum forum.php [NC,L]

RewriteRule ^fcategory/([0-9]+) forum.php?fcategory=$1 [NC,L]

RewriteRule ^ftopic([0-9]+) forum.php?ftopic=$1 [NC,L]

Looks like you missed the slash between ftopic([0-9]+)在最后一个规则中,在你的模式中。CBROE
Oh im so embarrassed! :D Thank you!Clude1987
RewriteRule ^index index.php [NC,L]威尔肯定会创建一个重写循环。RewriteRule ^forum forum.php [NC,L]Arkascha

回答 0