我前段时间使用子弹做了一个小项目,当时一切正常。现在,当我尝试打开一个子弹时,出现“找不到对象”页面和404错误。
这是我的.htaccess文件:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /benc/$1 [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /benc/index.php [L,QSA];
通过此功能,我会在首页上显示一些博客(带有链接到单个博客或slug的标签):
function showBlogs($limit) {
global $conn;
$result = mysqli_query($conn, "SELECT a.*, b.* FROM blogs a, slugs b WHERE b.blogID = a.idBlog");
while ($row = mysqli_fetch_array($result)) {
echo '<div class="container_blogs" id="' . $row['idBlog'] . '">';
echo '<h1 class="title_blog">' . $row['title'] . '</h1>';
echo '<h3 class="desc_blog">' . $row['blogDesc'] . '</h3>';
echo '<p class="text_blog">' . $row['content'] . '</p>';
echo '<div class="link_container"><a href="http://localhost:8080/benc/' . $row['slug'] . '">' . "Read more" . '</a></div>';
echo '</div>';
}
}
这是用于在单独页面上显示单个博客的代码:
global $conn;
define("SYSTEMNAME","TENPCMS1.0");
//include files after defining slug, there's a check to prevent direct execution of php files.
// include_once('template.php');
include_once('database.php');
// include_once('fetch_mysql.php');
$root = '/benc/';
//de root moet straks worden opgehaald uit mysql
$url = $_SERVER['REQUEST_URI'];
$slug = str_replace($root,"",$url);
define("SLUG", $slug);
define("DOMAIN", $_SERVER['HTTP_HOST']);
if(SLUG == NULL ){
function showBlog() {
?>
<h1>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.
Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes,
nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.</h1>
<a href="#"><i class="fas fa-angle-right"></i> Nieuwe Website</a>
<?php
}
}
else {
function showBlog() {
global $conn;
global $slug;
$slugs = "SELECT a.* FROM blogs a, slugs b WHERE a.idBlog=b.blogId AND b.slug='$slug'";
// $slug = "SELECT * FROM blogs WHERE idBlog = $slugs";
$result = $conn->query($slugs);
while ($row = mysqli_fetch_array($result)) {
echo '<div class="container_blogs">';
echo '<div class="blog_container_p" id="' . $row['idBlog'] . '">';
echo '<h1 class="blog_title_p">' . $row['title'] . '</h1>';
echo '<h3 class="blog_desc_p">' . $row['blogDesc'] . '</h3>';
echo '<p class="blog_text_p">' . $row['content'] . '</p>';
echo '</div>';
echo '</div>';
}
}
}
include_once('template.php');
谁能告诉我为什么我遇到“找不到对象”错误?
答案 0 :(得分:0)
没关系。我感觉像个白痴。多亏了我的Macbook,我的.htaccess文件更改为_htaccess ...直到一分钟前才注意到。