亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PHP 網站在重命名/添加新頁面后無法正常工作

PHP 網站在重命名/添加新頁面后無法正常工作

PHP
子衿沉夜 2023-05-12 14:19:45
在我的網站上,我有一個index.php帶導航欄的。然后,我需要添加另一個名為 的頁面second.php,并相應地更新我的導航欄代碼(我有一個nav.html導航欄文件,以便我可以使用 JS 將它加載到站點的每個頁面上)。我還將導航欄代碼添加到second.php. 但是,當我打開時,沒有出現index.php指向的鏈接。second.php我嘗試重新啟動我的計算機,重新啟動我的 MAMP 服務器,重新打開我的代碼編輯器,重新打開瀏覽器,但沒有任何效果。然后,我嘗試重命名我的文件(出于測試目的以及因為我需要更好的文件名)并相應地更新文件名的所有實例。但后來出現了:然后是我的目錄中的文件列表。特別是,該網站沒有顯示。有人可以解釋發生了什么以及我該如何解決嗎?nav.html:<body>    <header>        <div class="logo">            <h1 class="logo-text"><a href="home.php">Welcome!</a></h1>        </div>        <i class="fa fa-bars menu-toggle"></i>        <ul class="nav">            <li><a href="home.php">Home</a></li>            <li><a href="about.php">About</a></li>        </ul>    </header></body>home.php(以前second.php):<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <meta http-equiv="X-UA-Compatible" content="ie-edge">    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">    <link rel="stylesheet" href="css/style.css?v=<?php echo time(); ?>">    <!-- Font Awesome -->    <link rel="stylesheet" href="//use.fontawesome.com/releases/v5.0.7/css/all.css">    <!-- Fonts -->    <link href="https://fonts.googleapis.com/css2?family=Kalam&family=Pangolin&display=swap" rel="stylesheet">    <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">    <!-- JQuery -->    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>    <title>Welcome Home</title></head><body>    <div class="placeholder"></div>    <script>        $(function(){            $('.placeholder').load("nav.html");        });    </script>        hello world    <script src="js/main.js"></script></body></html>about.php(以前的)與除了它有幾個段落標簽外index.html基本相同。home.php
查看完整描述

1 回答

?
慕村225694

TA貢獻1880條經驗 獲得超4個贊

我不清楚此時有什么不起作用,所以我不妨分享一個我在本地的工作示例。我正在訪問我的站點http://localhost/so/,然后轉到該 URL 將加載index我擁有的任何頁面。我在/so目錄中有 3 個文件:


nav.html(我刪除了你的<body>標簽,因為那些已經存在于其他文件中):


<header>

    <div class="logo">

        <h1 class="logo-text"><a href="home.php">Welcome!</a></h1>

    </div>

    <i class="fa fa-bars menu-toggle"></i>

    <ul class="nav">

        <li><a href="home.php">Home</a></li>

        <li><a href="about.php">About</a></li>

    </ul>

</header>

home.php(可在 localhost/so/home.php 訪問):


<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie-edge">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">

    <link rel="stylesheet" href="css/style.css?v=<?php echo time(); ?>">


    <!-- Font Awesome -->

    <link rel="stylesheet" href="//use.fontawesome.com/releases/v5.0.7/css/all.css">


    <!-- Fonts -->

    <link href="https://fonts.googleapis.com/css2?family=Kalam&family=Pangolin&display=swap" rel="stylesheet">

    <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">


    <!-- JQuery -->

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>


    <title>Welcome Home</title>

</head>

<body>

   <?php include "./nav.html"; ?>


    hello world home


    <script src="js/main.js"></script>


</body>

</html>

http://img1.sycdn.imooc.com//645ddaa300016f8e03070283.jpg

about.php(可在 localhost/so/about.php 訪問):


<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie-edge">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">

    <link rel="stylesheet" href="css/style.css?v=<?php echo time(); ?>">


    <!-- Font Awesome -->

    <link rel="stylesheet" href="//use.fontawesome.com/releases/v5.0.7/css/all.css">


    <!-- Fonts -->

    <link href="https://fonts.googleapis.com/css2?family=Kalam&family=Pangolin&display=swap" rel="stylesheet">

    <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">


    <!-- JQuery -->

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>


    <title>Welcome About</title>

</head>

<body>

   <?php include "./nav.html"; ?>


    hello world about


    <script src="js/main.js"></script>


</body>

</html>

http://img1.sycdn.imooc.com//645ddab10001910103060278.jpg

如果我重命名home.php為,index.php那么我可以轉到localhost/so/localhost/so/index.php訪問該文件。

http://img1.sycdn.imooc.com//645ddabb000134ef02900264.jpg

稍微相關:您不一定要用作time()CSS 緩存破壞變量,因為它根本不會緩存。$css_cache_bust = "2020061001";您應該使用手動調整 (ie )值的變量,href="css/style.css?v=<?= $css_cache_bust; ?>"這樣您就可以根據需要逐步調整它。



查看完整回答
反對 回復 2023-05-12
  • 1 回答
  • 0 關注
  • 163 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號