Forum Moderators: phranque

Message Too Old, No Replies

What is the difference between an Alias and a ScriptAlias

         

IanTurner

7:34 pm on May 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I need to understand why I can't do

ScriptAlias /scripts "/usr/local/scripts/wwwroot/cgi-bin/"

Alias /this "/scripts/myperl.pl?param=1"

and have

http://www.example.com/this

work when

http://www.example.com/scripts/myperl.pl?param=1

will work okay

StupidScript

11:37 pm on May 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Alias URL-path file-path¦directory-path
Maps URLs to filesystem locations

ScriptAlias URL-path file-path¦directory-path
Maps URLs to filesystem locations AND designates the target as a CGI script

Essentially ScriptAlias aliases the location and informs Apache that files in that directory are intended to be executable.

If you are trying to set up a file within the directory as an Alias, and have it be executable, then you'll want to use ScriptAlias.

You may be having an issue setting an Alias that is a child of a ScriptAlias, and you'll want to simply set up two ScriptAliases with the full path to handle it:

ScriptAlias /scripts "/usr/local/scripts/wwwroot/cgi-bin/"

ScriptAlias /this "/usr/local/scripts/wwwroot/cgi-bin/myperl.pl?param=1"

or even in any other directory:

ScriptAlias /this "/usr/somestuff/myperl.pl?param=1"

Is this what you are wondering about?

IanTurner

5:44 pm on May 6, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I tried setting up two script aliases and it didn't work with the file with the parameters added.

jdMorgan

5:56 pm on May 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The Alias directive syntax shows that it expects a filepath as the second argument. So it may simply be that Apache does not recognize a URL query string as (part of) a filepath.

You should be able to use mod_rewrite to do an internal server rewrite to accomplish the same thing, though.

Jim

StupidScript

11:41 pm on May 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah ... I seem to remember experimenting with parameters a long time ago and was being nagged by the feeling that they didn't work ... but I guess I'm too lazy to check it. ;)

In addition to the mod_rewrite approach, what about simply pointing to the script without the parameter and using the parameter as the default in the script itself? (i.e. if!param { param=1 }) That way it should fire and give you the same result you would have gotten if the param were passed, and when a param is actually passed by a different invocation it should override the default ... maybe?

ScriptAlias /this "/usr/local/scripts/wwwroot/cgi-bin/myperl.pl"

and then invoking it with a different param:

http://yadda.com/this/?param=2

(Still too lazy to check it ... :( )