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
43
votes
12 answers

~/ equivalent in javascript

Any smart way of doing a "root" based path referencing in JavaScript, just the way we have ~/ in ASP.NET?
Vikram
  • 6,865
  • 9
  • 50
  • 61
42
votes
3 answers

What does a dot mean in a URL path?

In a question regarding a jQuery Ajax problem, the asker was trying to use a . in the beginning of a relative URL. I advised him to remove it, but have no idea what a dot actually does there. His relative URL looked like…
kapa
  • 77,694
  • 21
  • 158
  • 175
41
votes
2 answers

How do I use a relative path in a Python module when the CWD has changed?

I have a Python module which uses some resources in a subdirectory of the module directory. After searching around on stack overflow and finding related answers, I managed to direct the module to the resources by using something like import…
jvkersch
  • 575
  • 1
  • 4
  • 9
40
votes
7 answers

What does the dot-slash do to PHP include calls?

A. What does this do? require ("./file.php"); B. in comparison to this? require ("file.php"); (Its not up-one-directory.. which would be) require ("../file.php");
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
37
votes
2 answers

Is the HTML tag also honored by scripting and CSS?

The base HTML element provides a base for relative URIs in the HTML. Must JavaScript and CSS also honor it for relative URIs issued in them: E.g. JavaScript: location.href = "mypage.htm"` CSS: h4 { background-image: url(myimage.gif) } (in…
John K
  • 28,441
  • 31
  • 139
  • 229
35
votes
2 answers

VSCode Copy Relative Path with posix forward slashes

VSC newbie here. I'm trying to right-click on my projects' files and selecting Copy Relative Path, the thing is I get the path like this: node_modules\bootstrap\dist\css\bootstrap.min.css when what I actually need is…
KrOo Pine
  • 451
  • 4
  • 5
34
votes
1 answer

Struggling to append a relative path to my sys.path

So there are a lot of pretty similar questions but none of the answers seems to satisfy what I'm looking for. Essentially I am running a python script using an absolute directory in the command line. Within this file itself, I want to import a…
user2564502
  • 937
  • 2
  • 10
  • 16
34
votes
5 answers

In C#, how do I combine more than two parts of a file path at once?

To combine two parts of a file path, you can do System.IO.Path.Combine (path1, path2); However, you can't do System.IO.Path.Combine (path1, path2, path3); Is there a simple way to do this?
Matthew
  • 28,056
  • 26
  • 104
  • 170
34
votes
10 answers

Rails redirect with https

I'm maintaining a Ruby on Rails site and I'm confused as to how to perform redirects to relative URLs using the https protocol. I can successfully create a redirect to a relative URL using http, for example: redirect_to "/some_directory/" But I…
Brian D'Astous
  • 1,314
  • 1
  • 18
  • 26
31
votes
4 answers

How To Join Relative URLs in JavaScript

I want to join two strings each representing a relative URL in Javascript. I want to join the base URL http://www.adress.com/more/evenmore with the following examples: ../../adress (with the expected output: http://www.adress.com/adress) ../adress …
heffaklump
  • 1,526
  • 3
  • 21
  • 27
30
votes
2 answers

How can I import files in Python using sys.path.append?

There are two directories on my desktop, DIR1 and DIR2 which contain the following files: DIR1: file1.py DIR2: file2.py myfile.txt The files contain the following: file1.py import sys sys.path.append('.') sys.path.append('../DIR2') import…
makansij
  • 9,303
  • 37
  • 105
  • 183
30
votes
7 answers

Wrong extraction of .attr("href") in IE7 vs all other browsers?

Can it really be true that the attr("href") command for a link is handled very different in IE7 in comparison to all other browsers? Let's say I have a page at http://example.com/page.html and I have this HTML:
EmKay
  • 1,089
  • 1
  • 13
  • 28
29
votes
3 answers

How to find the working folder of a servlet based application in order to load resources

I write a Java servlet that I want to install on many instances of Tomcat on different servers. The servlet uses some static files that are packed with the war file under WEB-INF. This is the directory structure in a typical installation: -…
29
votes
7 answers

How to get the absolute path for a given relative path programmatically in Linux?

How to get the absolute path for a given relative path programmatically in Linux? Incase of Windows we have the _fullpath() API. In other words, I mean what is analogous API to _fullpath of Windows in Linux?
Jay
  • 24,173
  • 25
  • 93
  • 141
29
votes
3 answers

How to rewrite urls of images in vendor CSS files using Grunt

I am trying to move frontend dependencies out of the version control system. A combination of Bower.io and Grunt should be able to do this. A problem however occurs that I am yet unable to solve with bundling multiple vendor libraries. For example…
Roel van Duijnhoven
  • 800
  • 1
  • 7
  • 24