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 关注
- 139 浏览
添加回答
举报