Questions tagged [relative-path]

Relative-paths are URI or directory links to resources that refer to a location relative to the current path.

A relative path references a resource in relation to a current path or directory; its opposite is an absolute path. Web pages frequently make use of relative paths to refer to resources like images and scripts. The advantage of using a relative path is that it remains valid when the host name or root path changes.

As an example, consider a website located at the URL:

http://www.hostname.com/site/page.html

If the page wants to reference an image located at:

http://www.hostname.com/site/images/image.jpg

It could simply make reference to the relative path images/image.jpg.

2470 questions
124
votes
6 answers

Are PHP include paths relative to the file or the calling code?

I'm having trouble understanding the ruleset regarding PHP relative include paths. If I run file A.PHP- and file A.PHP includes file B.PHP which includes file C.PHP, should the relative path to C.PHP be in relation to the location of B.PHP, or to…
Yarin
  • 173,523
  • 149
  • 402
  • 512
120
votes
9 answers

How to construct a WebSocket URI relative to the page URI?

I want to construct a WebSocket URI relative to the page URI at the browser side. Say, in my case convert HTTP URIs…
neuront
  • 9,312
  • 5
  • 42
  • 71
118
votes
5 answers

What's a "canonical path"?

So, an absolute path is a way to get to a certain file or location describing the full route to it, the full path, and it's OS dependent (the absolute paths for Windows and Linux, for example, are different). A relative path, on the other hand, is a…
Metafaniel
  • 29,318
  • 8
  • 40
  • 67
117
votes
9 answers

Determining application path in a Python EXE generated by pyInstaller

I have an application that resides in a single .py file. I've been able to get pyInstaller to bundle it successfully into an EXE for Windows. The problem is, the application requires a .cfg file that always sits directly beside the application in…
Soviut
  • 88,194
  • 49
  • 192
  • 260
112
votes
4 answers

NodeJS - convert relative path to absolute

In my File-system my working directory is here: C:\temp\a\b\c\d and under b\bb there's file: tmp.txt C:\temp\a\b\bb\tmp.txt If I want to go to this file from my working directory, I'll use this path: "../../bb/tmp.txt" In case the file is not exist…
cheziHoyzer
  • 4,803
  • 12
  • 54
  • 81
106
votes
6 answers

Visual Studio: Relative Assembly References Paths

When adding a reference to an assembly located within the solution directory, is there any way to add it relatively, so that when checked in and out of a repository it is referenced in projects correctly?
theringostarrs
  • 11,940
  • 14
  • 50
  • 63
105
votes
8 answers

File Uri Scheme and Relative Files

Assume that the scheme for a uri is "file". Also assume that the path starts with '.' An example path is './.bashrc'. How would the fulluri look? 'file://./.bashrc' appears odd to me.
user592419
  • 5,103
  • 9
  • 42
  • 67
105
votes
8 answers

Relative path to absolute path in C#?

I have xml files that contain href file paths to images (e.g. "....\images\image.jpg"). The hrefs contain relative paths. Now, I need to extract the hrefs to the images and turn them into absolute paths in the file system. I know about the…
Anders
  • 12,556
  • 24
  • 104
  • 151
105
votes
13 answers

Failed to load resource: the server responded with a status of 404 (Not Found)

I can't solve my link problem. Could you help on to this to link CSS and JS File? CSS:
user3331535
  • 1,127
  • 3
  • 13
  • 14
101
votes
9 answers

How to avoid using relative path imports (/../../../redux/action/action1) in create-react-app

I've been using create-react-app package for creating a react website. I was using relative paths throughout my app for importing components, resources, redux etc. eg, import action from '../../../redux/action I have tried using module-alis npm…
Prem
  • 1,447
  • 2
  • 10
  • 21
101
votes
2 answers

How to make an "always relative to current module" file path?

Let's say you have a module which contains myfile = open('test.txt', 'r') And the 'test.txt' file is in the same folder. If you'll run the module, the file will be opened successfully. Now, let's say you import that module from another one which is…
user975135
99
votes
3 answers

How to use relative/absolute paths in css URLs?

I have a production and development server. The problem is the directory structure. Development:…
johnlemon
  • 20,761
  • 42
  • 119
  • 178
98
votes
3 answers

Get value from the cell above

Is it possible in Google Spreadsheets to reach the value of the cell just above? Meaning: In one cell A2 I want to display the value from the cell above, that is A1. Not because it is that coordinate, but because it is the cell above. I do this by…
Steeven
  • 4,057
  • 8
  • 38
  • 68
93
votes
3 answers

How to execute programs in the same directory as the windows batch file?

I have in the same folder a .bat and a .exe file. I couldn't call the .exe file from the .bat unless I put the full absolute path to it. Is there a way to don't specify the path?
Jader Dias
  • 88,211
  • 155
  • 421
  • 625
93
votes
3 answers

Relative path in HTML

I am creating a website on localhost. I want to make all of link resources in my website to relative path ( I mean only internal resources). website is located in http://localhost/mywebsite I read this useful question Absolute vs relative URLs. I…
Amir
  • 1,009
  • 1
  • 9
  • 11