Javascript 在.php加载不带css和js的页面后,在url上添加斜杠
正如标题所说,我在加载像这样的页面时遇到了问题 blabla/index.php,末尾有一个斜杠(blabla/index.php/)。它加载页面时没有css和js,使页面看起来像崩溃了一样。这在我拥有的每个页面中都会发生,比如blablabla/projects.php/等等。 你知道我该怎么解决这个问题吗?为什么会这样 代码是: 在head.php中Javascript 在.php加载不带css和js的页面后,在url上添加斜杠,javascript,php,css,Javascript,Php,Css,正如标题所说,我在加载像这样的页面时遇到了问题 blabla/index.php,末尾有一个斜杠(blabla/index.php/)。它加载页面时没有css和js,使页面看起来像崩溃了一样。这在我拥有的每个页面中都会发生,比如blablabla/projects.php/等等。 你知道我该怎么解决这个问题吗?为什么会这样 代码是: 在head.php中 <DOCTYPE html> <html> <head> <title>
<DOCTYPE html>
<html>
<head>
<title>ΑPL Lifts</title>
<link rel = "stylesheet" href = "css/bootstrap.css">
<link rel = "stylesheet" href = "css/main.css">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, user-scalable = no">
<meta http-equiv="content-type" content="text/html" charset = "UTF-8">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src = "js/bootstrap.js"></script>
</head>
ΑPL升降机
在另一个文件中:
<?php
include 'includes/head.php';
include 'includes/navigation.php';
include 'includes/leftContentColumn.php';
?>
<div class = "col-md-8 maincontent">
<h1 class = "main-title">Προφίλ Εταιρίας</h1><hr>
<div id = "profile">
<div id = "profileParOne" class = "col-md-11">
</div>
</div>
</div>
<?php
include 'includes/rightContentColumn.php';
include 'includes/footer.php';
?>
∏ροφίλΕταριας
我认为css和js的路径是相对的。例如../myscript.js。您应该将其重写为使用绝对路径(相对于根),如/js/myscript.js好的,我通过将ccs和js路径更改为:
<link rel = "stylesheet" href = "http://localhost/apl/css/bootstrap.css">
<link rel = "stylesheet" href = "http://localhost/apl/css/main.css">
<script src = "http://localhost/apl/js/bootstrap.js"></script>
您是如何调用您的资产的?您是否可以共享您认为导致问题的代码?如果没有代码可以查看,任何人都很难知道为什么会发生这种情况。