Reputation: 610
I am running a simple HTTP server using python. I have an HTML file with the following script tag:
<script src="../../build/react.js"></script>
The file is present in the right place if the relative URL is followed, but both Chrome and Firefox, look for base/build/react.js instead of base/../../build/react.js.
I remove the relative path, and it works fine as expected. Why are the relative paths not working?
Upvotes: 0
Views: 3683
Reputation: 332
Perhaps could you define "base"?
My answer assumes that "base" is the "base URL/domain" of your website:
e.g. base == http://www.google.com/
The base directory is essentially acting as the root of your directory... accessing the parent of the root directory is a logical fallacy (a root has no parent). When you seek the parent of a root directory, most programs will simply return the root.
For example, I'm assuming your site has the following layout:
www.google.com/
├── css/
│ └── theme.css
├── js/
│ └── jquery.js
└── html/
└── home.html
Suppose home.html
uses the following code:
<link href="../css/theme.css" rel="stylesheet">
<script src="../../js/jquery.js"></script>
Because the parent directory of html/
is the root directory, both will translate to:
www.google.com/css/theme.css
www.google.com/js/jquery.js
Upvotes: 1