TyLO TyLO - 11 months ago 50
CSS Question

Why apache does not look for assets in the current project?

I just installed apache and i'm running a simple project but something weird is happening. Apache try to look for assets in the wrong place, let's take an image for example. Apache goes to "localhost/images/IMAGE_NAME" instead of "localhost/PROJECT_NAME/images/IMAGE_NAME". How can i configure it so it look for assets in the right place ?.
this is my index page :

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>BlackBird Co.</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/style.css">
<link rel="icon" type="image/png" href="images/favicon.png">
<header class="bird-box">
<div class="back-bird"></div>
<div class="logo"></div>
<div class="fore-bird"></div>
<section class="content">
<h1>Clothing Store</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa.</p>
<div style="height: 2000px"></div>
<script src="/js/jquery-2.1.3.min.js"></script>
<script src="/js/functions.js"></script>

Thank you.

Answer Source

So (As was mentioned in the OP's comments), the issue here was with the path names beginning with a slash (i.e. "/images/IMAGE_NAME" instead of "images/IMAGE_NAME").

When on linux box, beginning with a slash indicates an absolute path rather than a relative one. It can be an annoying but common error to make, so if your filenames aren't resolving, it's a good place to start looking! It's usually the little things...