在没有 css 和 js 的情况下加载页面后.php网址上添加斜杠

Adding slash on url after .php loads page without css and js

本文关键字:php 添加 css js 加载 情况下      更新时间:2023-09-26

正如标题所说,我在加载页面时遇到问题,例如blabla/index.php末尾有一个斜杠(blabla/index.php/)。它加载页面而不使用 css 和 js,使页面看起来像崩溃了。这发生在我拥有的每个页面中,例如blabla/projects.php/等。知道我该如何解决这个问题吗?为什么会这样?

代码是:

在脑海中.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';
?>

我认为你的css和js的路径是相对的。/我的脚本.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>