php - 服务器未检测到 CSS 样式表路径 404 not found 错误?

标签 php css

我有一个名为 header.php 的头文件,如下所示:

它位于一个名为 includes 的文件夹中,因此路径为 includes/header.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html dir="ltr" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>***</title>
        <link rel='stylesheet' href='../_layout/scripts/jquery.fullcalendar/fullcalendar.css' type='text/css' media='screen' />
        <link rel='stylesheet' href='../_layout/scripts/jquery.fullcalendar/fullcalendar.print.css' type='text/css' media='print' />
        <!-- Styles -->
        <link rel='stylesheet' href='style.css' type='text/css' media='all' />
        <!--[if IE]>

            <link rel='stylesheet' href='../_layout/IE.css' type='text/css' media='all' />      

        <![endif]-->
        <!-- Fonts -->
        <link href='http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold|PT+Sans+Narrow:regular,bold|Droid+Serif:i&amp;v1' rel='stylesheet' type='text/css' />

            <script type='text/javascript' src='../../../ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min97e1.js?ver=1.7'></script>
        <!-- WYSISYG Editor -->
        <script type='text/javascript' src='../_layout/scripts/nicEdit/nicEdit.js'></script>

        <!-- Forms Elemets --> 
        <script type='text/javascript' src='../_layout/scripts/jquery.uniform/jquery.uniform.min.js'></script>
        <link rel='stylesheet' href='../_layout/scripts/jquery.uniform/uniform.default.css' type='text/css' media='screen' />

        <!-- Scripts -->
        <script type='text/javascript' src='../_layout/custom.js'></script>


    </head>  
<body>

        <div id="layout">
            <div id="header-wrapper">
                <div id="header">
                    <div id="user-wrapper" class="fixed">
                        <div class="color-scheme">
                            </div>
                            <div class='user'>
                        <?php
                        if($_SESSION['user'] != 'NULL')
                        {
                        ?>
                        <img src="../_content/user-img.png" alt="" />
                        <span>Welcome <a href="#">Admin <?PHP echo $_SESSION['user']; ?></a></span>
                        <span class="logout"><a href="#">Logout</a></span>
                        <?php
                        }
            ?>


                    </div>
                     </div>
                    <div id="launcher-wrapper" class="fixed"><img src="../_layout/images/NGBU Logo.png" width="68" height="81" alt="logo" style="margin-left:35px;" /> <img src="../_content/NGBU_logo.png" width="777" height="57" alt="logo" longdesc="http://index.php" style="margin-top: 25px; float: left; margin-left: 25px;"/></div>


            </div>
            </div>

我在 Index.php 的开头调用了这个文件,但由于某些原因,它没有从托管服务器呈现,尽管当我在 localhost 下测试它时它正在呈现?

我在文件夹 admin 中的 index.php 如下所示:
<?PHP
session_start();
ob_start();
$_SESSION['user'] = "NULL";
$_SESSION['password'] = "";
$_SESSION['error'] = 0;
include_once("../includes/header.php");
if(!$_SESSION['error'])
$_SESSION['error'] = "Please Login to Continue";
?>
<?PHP
if(isset($_REQUEST['check']))
{
    if(!$_REQUEST['User'] == "")
    {
        if(!$_REQUEST['Password'] == "")
        {
            $_SESSION['user'] = $_REQUEST['User'];
            $_SESSION['password'] = $_REQUEST['Password'];
            unset($_SESSION['error']);
            header('Location: checklogin.php'); 
        }
        else
        {
        $_SESSION['error'] = "<FONT color='#FF0000'>Both fields are required</FONT>";
        }
    }
    else
    {
    $_SESSION['error'] = "<FONT color='#FF0000'>Both fields are required</FONT>";
    }
}
?>
<DIV class="page fixed">
<DIV id="sidebar" style="height:400px; width:250px; margin-left:5px;"> </DIV>
<DIV id="content">
                <?PHP
echo "<h1 style='margin-left:150px;' >".$_SESSION['error']."</h1>";

?>
                <FORM action="index.php" method="post" name="loginfrm"  class="form-elements-inputs" style="margin-left:150px;width:90px;">
                <INPUT class="normal" type="text" name="User" value="User Name" /><BR />
                <INPUT class="normal" type="password" name="Password" value="Password"  /><BR />
                <INPUT type="hidden" name="check" value="login" />
                <INPUT type="submit" value="Login" class="button-orange" style="width:100px; margin:auto;"  />  
                    </FORM>
                </DIV>
    </DIV>
    </div>
    </BODY>
</HTML>

style.css 文件位于包含文件夹中的 header.php 旁边,那么为什么它没有被应用?

在通过Mozilla中的 Firebug 检查时,它向我展示了这个输出:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 2.0//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<title>***</title>
<link type="text/css" href="style.css" rel="stylesheet">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /style.css was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
<hr>
<address>Apache Server at www.***.com Port 80</address>
</body></html>
</link>
<link media="screen" type="text/css" href="scripts/jquery.fullcalendar/fullcalendar.css" rel="stylesheet">
<link media="print" type="text/css" href="scripts/jquery.fullcalendar/fullcalendar.print.css" rel="stylesheet">
<link media="screen" type="text/css" href="scripts/jquery.uniform/uniform.default.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold|PT+Sans+Narrow:regular,bold|Droid+Serif:i&v1">
<script src="../../../ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min97e1.js?ver=1.7" type="text/javascript">
<script src="../_layout/scripts/nicEdit/nicEdit.js" type="text/javascript">
<script src="../_layout/scripts/jquery.uniform/jquery.uniform.min.js" type="text/javascript">
<script src="../_layout/custom.js" type="text/javascript">
</head>
<body>
</html>

为什么路径正确时会出现 404 not found 错误?

请帮忙

最佳答案

您包括 ../include/header.php并且 style.css 也在那里,即 ../include/style.css .因此,您必须使用相同的相对路径或 css 的绝对路径 /include/style.css .

关于php - 服务器未检测到 CSS 样式表路径 404 not found 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63375429/

相关文章:

javascript - 平面列表延伸到屏幕之外

php - 我的 php 代码是否容易受到 SQL 注入(inject)攻击

php - 使用 PHP 接收和处理传入的电子邮件

php - 如何在同一台服务器上使用相同的 PHP 代码库运行多个网站?

sendmail - 如何在 MAC OS 中为 mail() 配置 php.ini 文件?

jquery - 加载默认最小化表格的页面

php - 如何回显此 MySQL 查询的结果?

javascript - 在两个 Angular 数组之间切换 z-index

css - 调用转发到 JSP 的 Servlet 时,浏览器无法访问/查找相关资源,如 CSS、图像和链接

jquery - 如何循环div的背景图?