Questions tagged [relative-url]

A URL that is relative to another URL.

For example "image/logo.gif" is a relative URL, which full path can only be resolved by taking into account its parent URL. For example if a document is located at http://example.com/test, the full URL of that image would be http://example.com/test/image/logo.gif.

132 questions
276
votes
12 answers

Absolute vs relative URLs

I would like to know the differences between these two types of URLs: relative URLs (for pictures, CSS files, JavaScript files, etc.) and absolute URLs. In addition, which one is better to use?
Haim Evgi
  • 123,187
  • 45
  • 217
  • 223
170
votes
2 answers

Two forward slashes in a url/src/href attribute

Possible Duplicate: URI starting with two slashes … how do they behave? Absolute URLs omitting the protocol (scheme) in order to preserve the one of the current page shorthand as // for script and link tags? anyone see / use this before? I was…
Michael Parkin
  • 1,855
  • 2
  • 12
  • 13
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
64
votes
4 answers

How to get "raw" href contents in JavaScript

I am trying to write a GreaseMonkey script in which I want to find all of the links that are relative links. It seemed to me that the way to do that would be to match the contents of href against /^https?:///. But I find that when I access the…
wfaulk
  • 1,765
  • 1
  • 17
  • 24
46
votes
5 answers

Why use protocol-relative URLs at all?

It's been an oft-discussed question on StackOverflow what this means: This gives the advantage that if you're accessing it over HTTPS, you get HTTPS automatically, instead of that…
oink
  • 1,443
  • 2
  • 14
  • 23
38
votes
6 answers

Absolute urls, relative urls, and...?

I am writing some documentation and I have a little vocabulary problem: http://www.example.com/en/public/img/logo.gif is called an "absolute" url, right? ../../public/img/logo.gif is called a "relative" url, right? so how do you call this:…
MiniQuark
  • 46,633
  • 36
  • 147
  • 183
28
votes
7 answers

PHP: How to resolve a relative url

I need a function that given a relative URL and a base returns an absolute URL. I've searched and found many functions that do it different ways. resolve("../abc.png", "http://example.com/path/thing?foo=bar") # returns http://example.com/abc.png Is…
Paul Tarjan
  • 48,968
  • 59
  • 172
  • 213
27
votes
4 answers

determine if a string is absolute URL or relative URL in java

Given a string, how do I determine if it is an absolute URL or a relative URL in Java? I tried the following code: private boolean isAbsoluteURL(String urlString) { boolean result = false; try { URL url = new URL(urlString); …
khalsa
  • 273
  • 1
  • 4
  • 5
19
votes
4 answers

Building an absolute URL from a relative URL in Java

I'm having trouble building an absolute URL from a relative URL without resorting to String hackery... Given http://localhost:8080/myWebApp/someServlet Inside the method: public void handleRequest(HttpServletRequest request, HttpServletResponse…
Marty Pitt
  • 28,822
  • 36
  • 122
  • 195
15
votes
4 answers

Is Java's URI.resolve incompatible with RFC 3986 when the relative URI contains an empty path?

I believe the definition and implementation of Java's URI.resolve method is incompatible with RFC 3986 section 5.2.2. I understand that the Java API defines how that method works, and if it were changed now it would break existing apps, but my…
Martin Pain
  • 713
  • 4
  • 18
13
votes
7 answers

Checking for relative vs absolute paths/URLs in PHP

I need to implement functions to check whether paths and urls are relative, absolute, or invalid (invalid syntactically- not whether resource exists). What are the range of cases I should be looking for? function check_path($dirOrFile) { // If…
Yarin
  • 173,523
  • 149
  • 402
  • 512
10
votes
3 answers

How can I convert a relative link in Mechanize to an absolute one?

Is there is a way to convert a Mechanize relative-link object to another one which contains the absolute URL. Mechanize must know the absolute link, because I can call the click method on relative links too.
Konstantin
  • 2,983
  • 3
  • 33
  • 55
7
votes
3 answers

Convert relative to absolute URLs in Go

I'm writing a little web crawler, and a lot of the links on sites I'm crawling are relative (so they're /robots.txt, for example). How do I convert these relative URLs to absolute URLs (so /robots.txt => http://google.com/robots.txt)? Does Go have a…
hiy
  • 449
  • 5
  • 15
7
votes
1 answer

relative url to absolute url in nodejs

I have url like this: http://example.com/path/to/css/../../images/test.jpg which i want to convert to absolute like the following: http://example.com/path/images/test.jpg I am looking for a module in Nodejs to do the same. The module, path, does the…
Learner
  • 315
  • 1
  • 5
  • 15
7
votes
3 answers

Rails relative_url doesnt adjust links

After failed attempts with Passenger (see my other question), I managed to get rails running via a reverse proxy in a subfolder. I added the lines config.relative_url_root = "/App" config.action_controller.relative_url_root = "/App" to my…
yell
  • 113
  • 1
  • 6
1
2 3
8 9