简体   繁体   中英

How to change my directory root in XAMPP

I'm using XAMPP and my root is C:/xampp/htdocs. Firstly, I will list my files:

I have index.php file on htdocs/public I have theme.css file on htdocs/public/css

I'm trying to link my css file to my html file like this:

<link rel="stylesheet" href="/css/theme.css" type="text/css">

But it doesn't work. When I right click to the browser and select "view source", and when I click to the href="/css/theme.css", it goes to this direction: http://localhost:8080/css/theme.css

But I want to make it go to this direction: http://localhost:8080/public/css/theme.css

How can I make this happen?

You have to indicate your current directory to include the css file, like this:

<link rel="stylesheet" href="./css/theme.css" type="text/css">

Here, ./ indicates the current directory.

Or , you can specify the file path relative to the root directory like this:

<link rel="stylesheet" href="/public/css/theme.css" type="text/css">

Or , you can just remove this /public/ altogether and include your css file like this:

<link rel="stylesheet" href="css/theme.css" type="text/css">

最直接的方法是:

<link rel="stylesheet" href="public/css/theme.css" type="text/css">

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