![](/img/trans.png)
[英]docker apache container serves /usr/local/apache2/htdocs as DocumentRoot instead of /var/www/html
[英]icons not loading when changing apache DocumentRoot “/var/www/”
我需要像DocumentRoot“/ var / www / cloud”一樣直接加載我的項目並正確加載圖標。
如何在css文件中給出正確的路徑? 這是我到目前為止所嘗試的:
background: url(../icons/twitter.png) no-repeat 0 0;
background: url(../../icons/twitter.png) no-repeat 0 0;
background: url(./icons/twitter.png) no-repeat 0 0;
background: url(icons/twitter.png) no-repeat 0 0;
main directory(cloud)
{
folder name (cloud/css)
-custom.css (file name)
-etc..
folder name (cloud/icons)
-fb.png (image file)
-twitter.png (image file)
-etc..
cloud/login.php
cloud/signup.php
cloud/etc
}
希望大家都明白我的文件夾結構。
如果我給這樣的apache根路徑 - DocumentRoot "/var/www/cloud"
- 我的圖標不加載。
如果我給這樣的apache根路徑 - DocumentRoot "/var/www/"
- 圖標效果很好。
在我的cloud / css / custom.css中:
.social-icons li.twitter a {
background: url(../icons/twitter.png) no-repeat 0 0;
//here is my problem . how i give the path here any suggestion
}
但我需要直接加載我的項目像DocumentRoot "/var/www/cloud"
並正確加載圖標。
謝謝大家。
如果您尚未在apache中設置virtualHost,那么您的站點URL仍將保留為localhost。 所以你應該嘗試訪問圖像
background: url(cloud/icons/twitter.png) no-repeat 0 0;
你也可以設置一個虛擬主機到var/www/cloud
說端口8001然后你可以使用相同的代碼background: url(icons/twitter.png) no-repeat 0 0;
並在http://localhost:8001
訪問該站點
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.