简体   繁体   中英

href is not working

I have a prolem when I want to load bootstrap. This is my bootstrap.min.css directory:

C:/xampp/htdocs/OOPPhp/perpustakaan/bootstrap/css/bootstrap.min.css

Then, I want to load it with this code:

<link href="<?= str_replace('\\', '/', baseDir); ?> /bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">

I have define baseDir before to get perpustakaan directory using this:

define('baseDir', dirname(__DIR__));

But link tag not working. I try to echo the link in href and the directory result is true. Why? This is my directory:

 /perpustakaan /bootstrap /css /bootstrap.min.css /js /images /ui /header.php /listCD.php /index.php 

The code is in header.php and I use include_once for header.php in listCD.php and index.php

尝试这个,

<link href="<?='http://'.$_SERVER['SERVER_NAME'].'/OOPPhp/perpustakaan';?>/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen"> ;

Can you try using relative path to solve the problem rather than using the basedir?

Using "../" to navigate 1 directory above.

 <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">

Using "./" to access root directory.

<link href="./css/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM