在.php加载页面后在URL上添加斜杠而不使用css和js

时间:2016-02-25 17:02:55

标签: javascript php css

正如标题所说,我在加载页面时遇到问题 blabla / index.php末尾有一个斜杠(blabla / index.php /)。它加载页面没有css和js使页面看起来像崩溃。这发生在每个页面我都喜欢blabla / projects.php /等 知道如何解决这个问题?为什么会发生这种情况?

代码是:

在head.php中

<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>

并在另一个档案中:

<?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';
?>

2 个答案:

答案 0 :(得分:0)

我认为你的css和js的路径是相对的。像../myscript.js这样的人。你应该重写它以使用绝对路径(相对于root),如/js/myscript.js

答案 1 :(得分:0)

好的,我通过将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>