qazerty23
qazerty23

Reputation: 491

Relative path in a HTML file

I have the following folder structure tree (folder names are written in uppercase letters):

ONLINESHOP
    |-- index.html
    |-- COMPONENTS
    |-- CONFIG
    |-- TEMPLATES
        |-- CSS
            |-- main-style.css
    |-- CONTROLLERS
    |-- MODELS
    |-- VIEWS
       ...
       |-- USER
           |-- login.html

So the root folder is OnlineShop. I am trying to reach main-style.css from login.html

This works:

<link rel="stylesheet" type="text/css" href="/OnlineShop/templates/css/main-style.css">

And this doesn't:

<link rel="stylesheet" type="text/css" href="/templates/css/main-style.css">

My question: why doesn't the later code work? Isn't / supposed to bring me to the root folder (OnlineShop)?

Upvotes: 1

Views: 1827

Answers (1)

luke
luke

Reputation: 3599

What is the web application root depends on your server configuration.

As an alternative you can use:

<link rel="stylesheet" type="text/css" href="../../templates/css/main-style.css">

Upvotes: 1

Related Questions