[Xitami] how to configure alias

Simon McVittie xitami@lists.xitami.org
Tue, 06 Nov 2001 12:41:01 +0000


> I'm using xitami under win98 and I've been playing with some esp. 
> scripts http://www.escapade.org  these scriptslive in the cgi-bin, but 
> the images live in a directory outside the cgi-bin
> http://localhost/cgi-bin/esp.exe?PAGE=abcwebsite2.esp like so, but any 
> images which are part of the script don't show in the browser when 
> called using relative url's in the script.
> E.G. this renders a place holder and no imge in the browser
> <IMG SRC="../../../images/bevel_bg.jpg" BORDER="0" WIDTH="150" 
> HEIGHT="40" ALIGN="bottom" ALT="">

This URL means "start from the current folder /cgi-bin/ (because the SRC 
doesn't start with "/"), go up 3 levels (../../../), go into the images/ 
folder, and get bevel_bg.jpg". You can't go up 3 levels from /cgi-bin/ 
because when you go up 1 level you get to the root folder, /, and you can't 
go up a level again from /; so you certainly can't go up 2 levels!

I'd suggest replacing all your image paths with something like 
SRC="/espimages/bevel_bg.jpg" which will go to the server root, then go 
into an espimages/ subfolder, then download bevel_bg.jpg; then put your 
images in an espimages subfolder of your web pages root (e.g. 
c:\xitami\webpages\espimages on a default install). (Xitami uses the images 
subdirectory already, for its own built-in images like the directory 
listing icons)

If you insist on using relative URLs, remember that they all have to be 
relative to where your CGI script is, i.e. relative to the cgi-bin folder.

Also remember that they're URLs and not file paths: if your cgi-bin is in 
c:\xitami\cgi-bin, you can't get to c:\images with ../../images/ - the "up 
one level" is handled by the user's Web browser, which has no idea where 
stuff is on your hard disk.

I realise this isn't particularly clear, so here's a silly example:

Suppose your server is set up with an alias for /docs/, as follows:

- / points to c:\xitami\webpages, like the default setup
- /cgi-bin/ points to c:\xitami\cgi-bin, again like the default setup
- /docs/ points to d:\my documents\public_html

Suppose you're looking at this site in a Web browser, and you're looking at 
http://myserver/docs/MyPlanToTakeOverTheWorld.html. When you go to this 
page, Xitami will look up what /docs/ means and return the contents of 
d:\my documents\public_html\MyPlanToTakeOverTheWorld.html. If this file 
contains a hyperlink to "../MoreRanting.html", you might expect that to 
mean d:\my documents\MoreRanting.html.

However, the ../ is resolved by the web browser, not the server. All the 
web browser knows is that it's at a server called http://myserver, in a 
folder called /docs/, looking at HereIsARant.html. So, it takes the current 
folder (/docs/), goes up one level (to /), and downloads MoreRanting.html 
from that folder - that's http://myserver/MoreRanting.html.

Xitami looks up what / means, looks for a file called MoreRanting.html, and 
dutifully returns c:\xitami\webpages\MoreRanting.html.

This is good, because it means there's no way a web browser can get at 
documents in folders you haven't specifically added to the server. For 
example, if it worked the way you seem to have assumed, the browser could 
request http://myserver/../defaults.aut and get c:\xitami\defaults.aut. 
This would be bad, because defaults.aut is a list of usernames and 
passwords for the password-protected pages on your server, if you have 
any... don't worry though, this doesn't actually happen.

For the same reason, to get a hyperlink to something you've stored in 
webpages from a script in cgi-bin, you just go "../something" or 
"/something", not "../webpages/something" - and to get from webpages to 
cgi-bin, you just go "cgi-bin" and not "../cgi-bin" (this would make no 
sense because you're already at the root as far as a web browser is 
concerned, so you can't go up any further).