473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

Hi,

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

-> ../bar.html

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

-> y/foo.html

Many thanks for any hint.

--
Gilles

Jul 18 '05 #1
3 4731
Am Mon, 27 Oct 2003 15:18:38 +0100 schrieb Gilles Lenfant:
Hi,

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.


I did this some time ago:
http://guettli.sourceforge.net/gthum...elative_url.py

Hope that helps,
Thomas

Jul 18 '05 #2
"Thomas Guettler" <gu*****@thomas-guettler.de> a écrit dans le message de
news: pa****************************@thomas-guettler.de...
Am Mon, 27 Oct 2003 15:18:38 +0100 schrieb Gilles Lenfant:
Hi,

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.


I did this some time ago:
http://guettli.sourceforge.net/gthum...elative_url.py

Hope that helps,
Thomas


It helped of course (it's exactly what I needed)

Many thanks Thomas

--
Gilles

Jul 18 '05 #3
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):
ce******@bcrenznvy.pbz. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V
ernq gur yvfg, fb gurer'f ab arrq gb PP.
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: tom pester | last post by:
Hi, Im new to php and have a background in asp. All the help is very much appreciated. today I was using the include function in a file that itself gets included : ***************...
6
by: openleren | last post by:
Hi all, how can I use a relative path in my web.config file for an Access db?: Instead of using <configuration> <appSettings> <add key="conAccess" value="microsoft.jet.oledb.4.0;data...
8
by: Daniel Serrano | last post by:
Hi, is it possible to use a relative path in a Connection string to access an Access database in a stand alone visual basic desktop application. All the examples that I have seen have absolute...
15
by: Lars Eighner | last post by:
Aside from the deaths of a few extra electrons to spell out the whole root relative path, is there any down side? It seems to me that theoretically it shouldn't make any difference, and it would...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.