473,386 Members | 1,873 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,386 software developers and data experts.

Relative URI puzzles

Well, they are puzzles for me, anyway!

On a linux/Apache shared host, a working web site has this directory
structure (for clarity, each directory name ends with "D"):

webD -- the FTP root
......htdocsD -- the DOCUMENT_ROOT
...........index.html
...........topicsD
................topic1.html
......imagesD
...........picture.jpg

If you put http://www.thesite.com/ in a browser address bar you see the
contents of index.html.

index.html contains this (I omit tag angle brackets to avoid confusing some
newsreaders):
img src="imagesD/picture.jpg" ...

As I understand it, this is a relative URI, and the server would look for
imagesD in the same directory that contains index.html. But imagesD is not
in that directory; it's in the parent directory, i.e., imagesD is a sibling
of the directory that contains index.html. How is this working?

topic1.html contains this:
img src="../imagesD/picture.jpg" ...
Again, this seems to me to target the jpg one level below where it really
resides, i.e., up to the parent of topicsD, i.e., htdocsD. But the jpg is
not in htdocsD, it's in htdocs's sibling directory, imagesD.

It's as if the resolution of the relative URIs allowed searching not only
the ending directory, but also its siblings.

On a related but not relative note, here is a form element that is included
(via PHP) on many pages of the site:
input type="image" name="Submit"
src="http://www.thesite.com/images/picture.jpg" ...

Thus there seem to be two document roots, webD (for fetching picture.jpg via
the abolute URI), and htdocsD (for fetching index.html via the URI mentioned
first above).

--
For mail, please use my surname where indicated:
st***@surname.reno.nv.us (Steve Brecher)
May 3 '06 #1
6 1435
Steve Brecher wrote:
Well, they are puzzles for me, anyway!

On a linux/Apache shared host, a working web site has this directory
structure (for clarity, each directory name ends with "D"):

webD -- the FTP root
.....htdocsD -- the DOCUMENT_ROOT
..........index.html
..........topicsD
...............topic1.html
.....imagesD
..........picture.jpg

If you put http://www.thesite.com/ in a browser address bar you see the
contents of index.html.
No, you see a G4TV webpage
index.html contains this (I omit tag angle brackets to avoid confusing some
newsreaders):
img src="imagesD/picture.jpg" ...

As I understand it, this is a relative URI, and the server would look for
imagesD in the same directory that contains index.html. But imagesD is not
in that directory; it's in the parent directory, i.e., imagesD is a sibling
of the directory that contains index.html. How is this working?


Look in the <head> of the page. Is there a <base> tag anywhere? It'd
probably look something like <base href="http://www.thesite.com/" />
That way the link "imagesD/picture.jpg" gets resolved to
"http://www.thesite.com/imagesD/picture.jpg"
Whereas typing in "http://www.thesite.com/" automatically goes to the
index page in the htdocsD directory because the server is set up to
*know* that that is what should be displayed (because it's much more
useful than people having to type
http://www.thesite.com/htdocsD/index.html; which is slightly less
human-usable/memorable).

Did you write the page yourself or did you use an HTML generator? If
there's no <base> tag then I can only assume that Apache has some sort
of inbuilt intelligence (though I'm guessing here; I don't know an awful
lot about Apache).
--
ironcorona
May 3 '06 #2
Steve Brecher wrote:
Well, they are puzzles for me, anyway!

On a linux/Apache shared host, a working web site has this directory structure (for clarity, each directory name ends with "D"):
webD -- the FTP root
.....htdocsD -- the DOCUMENT_ROOT
..........index.html
..........topicsD
...............topic1.html
.....imagesD
..........picture.jpg

If you put http://www.thesite.com/ in a browser address bar you see
the contents of index.html.
index.html contains this (I omit tag angle brackets to avoid confusing some newsreaders): img src="imagesD/picture.jpg" ...

As I understand it, this is a relative URI, and the server would look

for imagesD in the same directory that contains index.html. But imagesD
is not in that directory; it's in the parent directory, i.e., imagesD is
a sibling of the directory that contains index.html. How is this working?

Look in the <head> of the page. Is there a <base> tag anywhere? It'd
probably look something like <base href="http://www.thesite.com/" />
That way the link "imagesD/picture.jpg" gets resolved to
"http://www.thesite.com/imagesD/picture.jpg"
Whereas typing in "http://www.thesite.com/" automatically goes to the
index page in the htdocsD directory because the server is set up to
*know* that that is what should be displayed (because it's much more
useful than people having to type
http://www.thesite.com/htdocsD/index.html; which is slightly less
human-usable/memorable).

Did you write the page yourself or did you use an HTML generator? If
there's no <base> tag then I can only assume that Apache has some sort
of inbuilt intelligence (though I'm guessing here; I don't know an awful
lot about Apache).
--
ironcorona
May 3 '06 #3
Steve Brecher wrote:
Well, they are puzzles for me, anyway!

On a linux/Apache shared host, a working web site has this directory
structure (for clarity, each directory name ends with "D"):

webD -- the FTP root
.....htdocsD -- the DOCUMENT_ROOT
..........index.html
..........topicsD
...............topic1.html
.....imagesD
..........picture.jpg

If you put http://www.thesite.com/ in a browser address bar you see the
contents of index.html.

index.html contains this (I omit tag angle brackets to avoid confusing some
newsreaders):
img src="imagesD/picture.jpg" ...

As I understand it, this is a relative URI, and the server would look for
imagesD in the same directory that contains index.html. But imagesD is not
in that directory; it's in the parent directory, i.e., imagesD is a sibling
of the directory that contains index.html. How is this working?


Look in the <head> of the page. Is there a <base> tag anywhere? It'd
probably look something like <base href="http://www.thesite.com/" />
That way the link "imagesD/picture.jpg" gets resolved to
"http://www.thesite.com/imagesD/picture.jpg"
Whereas typing in "http://www.thesite.com/" automatically goes to the
index page in the htdocsD directory because the server is set up to
*know* that that is what should be displayed (because it's much more
useful than people having to type
http://www.thesite.com/htdocsD/index.html; which is slightly less
human-usable/memorable).

Did you write the page yourself or did you use an HTML generator? If
there's no <base> tag then I can only assume that Apache has some sort
of inbuilt intelligence (though I'm guessing here; I don't know an awful
lot about Apache).

--
ironcorona

--
ironcorona
May 3 '06 #4
Steve Brecher wrote:

On a linux/Apache shared host, a working web site has this directory
structure (for clarity, each directory name ends with "D"):

webD -- the FTP root
.....htdocsD -- the DOCUMENT_ROOT
..........index.html
..........topicsD
...............topic1.html
.....imagesD
..........picture.jpg

If you put http://www.thesite.com/ in a browser address bar you see the
contents of index.html.

index.html contains this (I omit tag angle brackets to avoid confusing some
newsreaders):
img src="imagesD/picture.jpg" ...

As I understand it, this is a relative URI, and the server would look for
imagesD in the same directory that contains index.html. But imagesD is not
in that directory; it's in the parent directory, i.e., imagesD is a sibling
of the directory that contains index.html. How is this working?

Can't say. How about an URL to the "working web site"?
My guess is that the directory structure is not as you describe it.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
May 3 '06 #5
On 03/05/2006 03:03, Steve Brecher wrote:

[snip]
webD -- the FTP root
.....htdocsD -- the DOCUMENT_ROOT
..........index.html
..........topicsD
...............topic1.html
.....imagesD
..........picture.jpg
If that's /really/ the directory structure then the contents of the
images directory wouldn't normally be accessible. However, it's possible
to map paths within a URI to directories on the server. With Apache,
this can be achieved with the Alias directive[1]. Rather than looking
for files in

/web/htdocs/images/

the server can be instructed to go to

/web/images/

instead.
If you put http://www.thesite.com/ in a browser address bar you see the
contents of index.html.


When providing URI examples, use the IANA-reserved .example second-level
domains: example.com, example.org, and example.net. There can then be no
mistake regarding what's an actual site, and a simple example.

[snip]

Mike
[1] The Alias directive
<http://httpd.apache.org/docs/2.0/mod/mod_alias.html#alias>

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
May 4 '06 #6
Steve Brecher:

Re your Subject line: Divide and Conquer. You can split up the
question of what a relative reference points to into (i) what the
relative reference resolves to, and (ii) what the resolved (absolute)
URL points to. The definitive source for (i) is RFC3986 section 5,
(ii) depends on how your server is configured.
webD -- the FTP root
.....htdocsD -- the DOCUMENT_ROOT
..........index.html
..........topicsD
...............topic1.html
.....imagesD
..........picture.jpg
Filesystem organisation is irrelevant to (i).

[supposing base URL of http://host.invalid/ ]
img src="imagesD/picture.jpg" ...


which resolves to the URL http://host.invalid/imagesD/picture.jpg .

What this URL points to depends on your server config.

Post a real URL.

--
Jock

May 4 '06 #7

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

Similar topics

3
by: Markus Ernst | last post by:
Hello Reading the follwing document: http://www.w3.org/TR/WD-positioning-970131#In-flow it seems very clear that position:relative should be relative to the parent element. So in the following...
5
by: PM | last post by:
Hello!!!! I am com sci student.... I am really interested in C... Does anybody know any free ebooks or websites for puzzles that test the intricacies of C... Please Help.... Casanova
2
by: xPy | last post by:
do you know any links where i can find puzzles, like the 8 queens problem? (I'm not intrested in the solution, only for puzzle...)
11
by: John Salerno | last post by:
Similar to the Python Challenge, does anyone know of any other websites or books that have programming puzzles to solve? I found a book called "Puzzles for Hackers", but it seems like it might be a...
8
by: JJ | last post by:
I'm confused about paths. I have a functionn that uses the mappath method, which I think requires a virtual path (is that the same as a relative path?). But this doesn't always work as the...
2
by: =?Utf-8?B?Q3JtTmV3Ymll?= | last post by:
Hi, 1) I want to hone my problem solving skills and be good at logic. How do I achieve this? 2) Where can I find c# puzzles or c# algorithms. 3) How do I print the values of a N X N matrix...
0
by: Kay Schluehr | last post by:
Since their introduction in Python 2.5 I only reviewed the new "relative import" notation briefly by reading the "What's new in Python 2.5" article. Now I wanted checkout if I get comfortable with...
25
by: Oltmans | last post by:
Hi guys, I'm learning JavaScript and I need some puzzles that can make me a better JavaScript programmer. I mean I'm looking out for programming puzzles (e.g. Project Euler or TopCoder) but I'm...
62
jkmyoung
by: jkmyoung | last post by:
Does anyone have some super, super hard Sudoku puzzles? Back in February this year, I had enough time to finally program a Sudoku solver in Java. Right now, I'm looking for solvable puzzles, but...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...

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.