php即使认为路由是正确的,也不会加载我的css

  • 本文关键字:加载 css 路由 php php
  • 更新时间 :
  • 英文 :


所以我试图制作我的第一个php应用程序,但我面临的问题是,当页面加载时,php文件没有加载控制台中的任何css,我得到了

GET http://localhost/PHP-CATALOG/public/assets/catalog/css/bootstrap.min.css net::ERR_ABORTED 404 (Not Found)

路线是正确的,但我不明白为什么找不到我?

配置

/* ROOT PATHS */
$path = str_replace("\", "/","http://" . $_SERVER['SERVER_NAME'] . __DIR__  . "/");
$path = str_replace($_SERVER['DOCUMENT_ROOT'], "", $path);
define('ROOT', str_replace("app/core", "public", $path));
define('ASSETS', str_replace("app/core", "public/assets", $path));

链接index.php页面中的css

<link rel="stylesheet" href="<?=ASSETS?>catalog/css/bootstrap.min.css">
<link rel="stylesheet" href="<?=ASSETS?>catalog/css/all.min.css">
<link rel="stylesheet" href="<?=ASSETS?>catalog/templatemo-style.css">

尝试使用其他浏览器点击f5+ctrl刷新,以防出现缓存问题,但没有任何效果。

解决了问题。这是因为我把xampp上的端口从80改为88

解决方案:

$path = str_replace("\", "/","http://" . $_SERVER['SERVER_NAME']. ":88". __DIR__  . "/");

最新更新