【问题标题】:Adding slash on url after .php loads page without css and js在.php加载页面后在url上添加斜杠没有css和js
【发布时间】:2016-02-26 05:36:22
【问题描述】:

正如标题所说,我在加载类似的页面时遇到问题 blabla/index.php 末尾带有斜线(blabla/index.php/)。它加载页面时没有 css 和 js 使页面看起来像崩溃了。这发生在我喜欢的每个页面中 blabla/projects.php / ETC。 知道如何解决这个问题吗?为什么会这样?

代码是:

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

【问题讨论】:

  • 你是怎么称呼你的资产的?
  • 您能分享您认为导致问题的代码吗?如果没有一些代码可以查看,任何人都很难说出它为什么会发生。

标签: javascript php css


【解决方案1】:

我认为你的 css 和 js 的路径是相对的。像 ../myscript.js 之类的东西。您应该重写它以使用绝对路径(相对于根),例如 /js/myscript.js

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-02
      • 1970-01-01
      • 1970-01-01
      • 2014-07-23
      • 1970-01-01
      • 2021-09-10
      相关资源
      最近更新 更多