relative-url

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 there a canonical way? On this site I see great examples for python and c#, lets get a...

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 anchor's href attribute, it's always normalized or cooked into a form that contains "http". ...

Switch to SSL using a relative URL

I would like to create a relative link that switches the current protocol from http to https. The last place I worked had something set up on the server so that you could make that happen, but I don't remember much about it and I never knew how it worked. The rationale for this is that I wouldn't need to hardcode server names in files t...

PHP - Calling Relative URL within = 'xx' apostrophe's

I'm trying to insert a relative URL in the code below before "/images" in $thumb_directory and $orig_directory however I'm not sure how to do so within 'apostrophe's'. Also, this is a WordPress website, so if anyone knows how to call the function within '/images', like so: '/images' please let me know (I realize that what I just typed ...