× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I was just gonna say, why don't you publish that! But Nathan beat me to
it...

Great write up, Scott!

Regards,

Mike

mike.p@xxxxxxxx Cell: (408)679-1011 Office: (815)722-3454


-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx]
On Behalf Of Scott Klement
Sent: Thursday, June 04, 2009 11:57 AM
To: Web Enabling the AS400 / iSeries
Subject: Re: [WEB400] Basic CGIDEV2 problem

Hi David,


I wish I fully understood all those Alias and ScriptAliasMatch lines,
though.

Alias, AliasMatch, ScriptAlias and ScriptAliasMatch aren't too hard to
understand. I'll try to explain them, but please ask questions if you
still don't understand.

BACKGROUND
----------
When you configure Apache, you give it a DocumentRoot. This is an IFS
pathname to the start of your web server. In the simplest
configuration, everything on your server would be under DocumentRoot.
So you might have this:

DocumentRoot /www/myserver/htdocs

HTTP was designed for fetching documents (originally, that's all you
could do, just fetch a document, nothing else). So a browser would code

something like this:

http://www.example.com/mydir/mydoc.html

This tells the browser (a) use the http protocol. (b), connect to
www.example.com, and (c) ask for the document named /mydir/mydoc.html

Apache will get that request, but it'll add the DocumentRoot to it. So
the actual IFS path to the document will be
/www/myserver/htdocs/mydir/mydoc.html

That's the simplest behavior. It lets you designate some part of your
IFS (DocumentRoot) where all subfolders will be accessible via URLs.
That's the basic configuration.

ALIAS
-----
What if you want something OUTSIDE of that area to be accessible to the
browser? How would you do it? You declare an Alias.

DocumentRoot /www/myserver/htdocs
Alias /foo /home/scott/bar

This says that all URLs go under /www/myserver/htdocs, just as in the
previous example... EXCEPT for /foo. Any URL starting with /foo will
point to /home/scott/bar

So this works just as it did before:
http://www.example.com/mydir/mydoc.html

But this works differently.
http://www.example.com/foo/mydir/mydoc.html

In this second case, the /foo is an alias for /home/scott/foo, so the
URL points to /home/scott/bar/mydir/mydoc.html.

That's all an alias does. It provides a way to specify directories in
the URL that are "redirected" to another area of the IFS, outside of the

document root.

ALIASMATCH
----------
AliasMatch does the same thing that Alias does, except it allows
"wildcards" (technically... Regular Expressions.) For example, I could
do something like this:

AliasMatch /foo/(.*jpg) /images/jpg/foo/$1

In a regular expression, a single dot matches any one character. An
asterisk says "zero or more of the preceding character". So when you
have .* it matches any number of any character. In this example, any
URL that begins with /foo/ and ends with jpg will match the alias.

In Apache, the parenthesis designate a section of the URL o be copied to

the resulting URL. So in this example, the /foo/ is not in parenthesis,

but the .*jpg is. So whatever matches the wildcard of .*jpg will be
considered "variable number 1". You'll notice the result is
/images/jpg/foo/$1 -- that $1 will be replaced at runtime with whatever
matched the .*jpg pattern.

Example:

http://www.example.com/foo/goofy/scott_dancing.jpg

Once the hostname is removed, it starts with /foo/ and ends with jpg, so

it matches the Alias. The (.*jpg) part will match
goofy/scott_dancing.jpg, so Apache will access the
/images/jpg/foo/goofy/scott_dancing.jpg file in the IFS

FWIW, I tend to avoid AliasMatch (or ScriptAliasMatch) since they run
slower, and IMHO, they're more complicated than I need for my projects.

SCRIPTALIAS
-----------
If you understood Alias, then ScriptAlias should be easy. There's
really only one difference. Alias is for fetching a document... it
tells Apache which document in the IFS to fetch. By contrast,
ScriptAlias is for running a script or program. Instead of downloading
the program object to the browser (that's what Alias would do),
ScriptAlias tells Apache to run the program. The output of the program
will be sent to the browser, instead of downloading the program object
itself.

Without ScriptAlias:

DocumentRoot /www/myserver/htdocs

http://www.example.com/qgpl/pmu010.pgm

This tells Apache to go to the /www/myserver/htdocs/qgpl directory and
download a program named pmu010.pgm to the browser.

With ScriptAlias:
DocumentRoot /www/myserver/htdocs
ScriptAlias /qgpl /QSYS.LIB/QGPL.LIB

http://www.example.com/qgpl/pmu010.pgm

Hopefully you already understand that /QSYS.LIB in the IFS provides
access to your traditional libraries and their contents. With that in
mind, Apache will build the IFS pathname of
/QSYS.LIB/QGPL.LIB/PMU010.PGM and it will therefore be equivalent of
CALL PGM(QGPL/PMU010)


SCRIPTALIASMATCH
----------------
Same as ScriptAlias, except it now has regular expressions ("wildcards")

available. ScriptAliasMatch is to ScriptAlias what AliasMatch is to
Alias.

The installer for CGIDEV2 likes to set things up like this:

ScriptAliasMatch /mylibp(.*).pgm /qsys.lib/mylib.lib/$1.pgm
AliasMatch /mylibh/(.*)\.htm /QSYS.LIB/MYLIB.LIB/HTMLSRC.FILE/$1.mbr
Alias /mylibh/ /QSYS.LIB/MYLIB.LIB/HTMLSRC.FILE/
Alias /mylib/ /mylib/

The ScriptAliasMatch at the top says that any URL that begins with
/mylibp and ends with .pgm should be run as a program in
/qsys.lib/mylib.lib. Contrast these two statements:

ScriptAlias /mylibp /qsys.lib/mylib.lib
ScriptAliasMatch /mylibp(.*).pgm /qsys.lib/mylib.lib/$1.pgm

In the first case, anything that starts with /mylibp (including files,
data areas, queues, user spaces, etc) will be run as a program from the
/QSYS.LIB/MYLIB.LIB library. Of course, if you list a program object, no

problem, it'll run it. If you list a non-program object, however,
Apache will still try to call it (though, it'll fail with an error.)

In the second case, only URLs that end in .PGM are called. Apache will
forcibly add the .pgm extension to it when it tries to call it.
Therefore, non-programs will not match this script alias. Instead,
they'll match this one (also from the configs, above)

Alias /mylib/ /mylib/

This tells it to go to the /mylib/ folder of the IFS instead of the
library. So program objects go to the library, non-program objects go
to an IFS folder. If you left off this extra Alias, it would go to the
DocumentRoot instead -- and go to /www/myserver/htdocs/mylib.

Shrug... I personally prefer to go in and delete the CGIDEV2 provided
instructions and insert my own. I don't like the instructions they
provide. They're more complicated than they need to be, IMHO.

But, anyway... hope this all made sense.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.