Why are my images not found on my web server?

I have a strange problem on my site. When I want to access images in folders, they are not displayed. I tried everything, but I do not understand.

My CSS also does not work, because my text does not change. It only works when you go to the main page.

I have 2 pages, for example, / contact / and / about /. They do not work.

Here is the complete list of my folder.

/ui/images/logo.jpg (etc...) /ui/css/site.css /javas/site.js /index.php 

here is my script (I removed some useless things)

 <?php $page = $_GET['page']; $conn = mysql_connect("localhost", "user", "password"); mysql_select_db("page"); $sql = "SELECT * FROM page WHERE page = '".$page."'"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); mysql_free_result($result); ?> <html> <body> <script type="text/javascript" src="javas/site.js"></script> <link rel="stylesheet" type="text/css" href="ui/css/site.css"> <?php echo $row['page']; ?> </body> </body> 

What can I do to fix this?

+7
source share
2 answers

Try using the full path, for example:

  http: //your_host/your_project/javas/site.js

Hope this helps

+11
source
  <script type="text/javascript" src="javas/site.js"></script> <link rel="stylesheet" type="text/css" href="ui/css/site.css"> 

The above two lines is your problem, since href = paths to .css and .js are incorrect for the contact page and about us, you tell /contact/index.php that it can find stylized text inside / contact / ui / css / , which is wrong, since you want to return to the root folder, go to / ui / css /

Use the added / similar for the .css and .js files you need, see below

  <script type="text/javascript" src="/javas/site.js"></script> <link rel="stylesheet" type="text/css" href="/ui/css/site.css"> 

The added / at the beginning of src and href will force it to return to the root directory first, and then search for these folders / files.

+1
source

All Articles