简体   繁体   中英

Link Files from Directory to directory

rootFolder

index.php

cssFolder
fontAwesomeFolder
-main.css
-tablet.css

imagesFolder
-image.jpg

includesFolder
-navMain.php
-footer.php

pagesFolder
-contactUs.php

jsFolder
-core.js

I have topology here about my website. Thing is, when I tried to link/include navMain.php in the includesFolder to the contactUs.php in the pageFolder , some other links are messed-up, particularly - css and images files. They don't seems to work.

The issue is the PHP INCLUDE. Alright. It works fine with the index.php. But not with the file in the subdirectories.

How am I going to bring this around. Some said, I'd use config.php. I tried, didn't work. If ever I'm going to use Config.php, what exact codes do I have to place in there and what codes to the other documents.

Thanks for the help!

The problem seems to be that your assets urls are relative to your file location. To avoid this you can always use / to make them relative to your root url and avoid getting 404 errors:

<link rel="stylesheet" type="text/css" href="/cssFolder/main.css" />
<link rel="stylesheet" type="text/css" href="/cssFolder/tablet.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