Chin
Chin

Reputation: 20675

Wrong file path with WAMP server

I have my site in this folder:

C:\wamp\www\site

and the stylesheets are in here:

C:\wamp\www\site\style

I have this in my index page (which is in the site folder):

<link href="/style/all.css" media="all" rel="stylesheet" type="text/css" />

but I got an error:

GET http://localhost/style/all.css 404 (Not Found) 

Why is it http://localhost/style/all.css but not http://localhost/site/style/all.css like I want it to be?

Upvotes: 0

Views: 790

Answers (2)

denoise
denoise

Reputation: 1097

just remove the slash / before url

<link href="style/all.css" media="all" rel="stylesheet" type="text/css" />

the slash acts as a root directory call

Upvotes: 1

Frank W
Frank W

Reputation: 891

With "/" you are starting from the root dir (DOCUMENT_ROOT) and I think in your case this is C:\wamp\www. But you can modify the root dir, or you define it like this:

<link href="./style/all.css" media="all" rel="stylesheet" type="text/css" />

Because "./" is relative from the current dir (C:\wamp\www\site).

Edit: Ok has been answered and solved already.

Upvotes: 0

Related Questions