.htaccess php中带重定向页面的htaccess

.htaccess php中带重定向页面的htaccess,.htaccess,http-status-code-404,.htaccess,Http Status Code 404,我在htaccess上编写以下代码 Options -Indexes RewriteEngine on RewriteBase /localhost_site_name/ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ ?page=$1 [L] # 404 redirect page start RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_

我在htaccess上编写以下代码

Options -Indexes

RewriteEngine on

RewriteBase /localhost_site_name/

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^([^/]+)/$ ?page=$1 [L]


# 404 redirect page start

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ error.php [L]

#404 redirect page end
我根据页面概念显示页面,所以我会在页面上显示详细信息之前检查页面。 这是我的索引文件

    <?php
        session_start();
        ob_start();
    ?>
    <!DOCTYPE html>

        <body>

        <?php 
          //echo "Page name is ".$page;

        if($page=="template" || $page=="user")
        {

               include("modal.php");
               include("topnav.php");

               include("sidebarnav.php");

               include("content.php");
               include("footer.php");

        }
        else
        {
            echo "<h1 style='background:#000;color:#fff;'>404 Error</h1>";
        }


        ?>

        </body>

    </html>