1 回答

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>
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>
如果我重命名home.php
為,index.php
那么我可以轉到localhost/so/
或localhost/so/index.php
訪問該文件。
稍微相關:您不一定要用作time()
CSS 緩存破壞變量,因為它根本不會緩存。$css_cache_bust = "2020061001";
您應該使用手動調整 (ie )值的變量,href="css/style.css?v=<?= $css_cache_bust; ?>"
這樣您就可以根據需要逐步調整它。
- 1 回答
- 0 關注
- 163 瀏覽
添加回答
舉報