Make a relative url path from an absolute path to another one

A

Andrei

Gilles Lenfant wrote on Mon, 27 Oct 2003 15:18:38 +0100:
I'm sometimes brain dead for a simple problem like this one :

Given an origin absolute URL and a destination absolute URL, I want to make
a relative path from the origin to the destination.

e.g

origin = http://www.stuff.com/x/y/foo.html
destination = http://www.stuff.com/x/bar.html

You could split the strings at every "/" and compare the items of the two
resulting lists until two unidentical items are found. Then you've found
the common bit and the different bit and it's not that hard to make a
relative link for that.

--
Yours,

Andrei

=====
Mail address in header catches spam. Real contact info (decode with rot13):
(e-mail address removed). Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V
ernq gur yvfg, fb gurer'f ab arrq gb PP.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top