www.domain.com/?variable ?????

Hi,

     I'm using NT4.0 and IIS 3.0 as my web server.  I would like to have a perl script as the default page (index.cgi).  I have configured IIS to make this happen...and it does work.
     The problem is that I want to be able to pass one variable to the script and have it create a web page on the fly from that variable.  I want to call it like this:

www.domain.com/?variable

  The script is called, but the variable does not appear in the QUERY_STRING.
    If I call the page like so:

www.domain.com/index.cgi?variable

the QUERY_STRING does contain the value "variable".  It appears that the script gets called regardless, but the variable doesn't get passed unless the script name is included.
     I really need to use the form 'www.domain.com/?variable.  I've seen other web sites that do it this way.  Any help in this matter would be appreciated.

Thanks,
Lance

lancejAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
atticusConnect With a Mentor Commented:
Hi, Lance.

I know what you're talking about, since I have a web site on freedomstarr.com and I programmed their calculator.  These lines of my code in my calculator might work:

if ($ENV{QUERY_STRING} ne "") {
      if ($ENV{QUERY_STRING} ne "?") {
            $Variable = $ENV{QUERY_STRING};
      }
}

In other words, have your program check to see that the ENV... string is not empty or just a ?.  If there's some meat there convert the ENV into your variable.
0
 
viroCommented:
Try this:

www.domain.com?variable


Hope it Help!

Vitor Rodrigues
  Portugal
0
 
lancejAuthor Commented:
Hi,

     I really appreciate Viro's response.  Unfortunately, the variable is not passed to QUERY_STRING.  I really need to find a way to pass the variable.  I hate to give a grade of "F",  it's just that the answer didn't work for my particular situation.

Thanks,
Lance

0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
mrmickCommented:
You need to add an "=" (equal) sign.

Example: www.host.domain/index.cgi?variable=

will pass the empty variable, or

Example: www.host.domain/index.cgi?variable=value

to pass a variable with an assigned value

mrmick
0
 
lancejAuthor Commented:
Hi,

I'm trying to call a perl script using a URL like:

www.domain.com/?smith    or
www.domain.com/?jones

I want the QUERY_STRING to contain either "smith" or "jones".  You can see an example of what I want to do by going to www.cnet.com.  Move the pointer to "GAMECENTER".  See how the URL is "www.gamecenter.com/?something"?  That's what I want to do.  I don't want the name of the script in the URL and I don't want to have something like "Variable=value".

Thanks for the help,
Lance

0
 
mrmickCommented:
Unfortunately, no.  When you type in the url with no arguments for example: www.cnet.com, IIS supplements with the default document as set up in the WWW Service Properties.  If you add any arguments, it assumes you're providing a document/script (weather you include arguments or not).  So... with out the script name, IIS will assume your variables are the name of the script/document you wish to access (and very unlikely will not find it unless you have a script by the same name).

You might try setting the default to something you wouldn't mind your clients seeing like go.cgi, for example:

www.gamecenter.com/go.cgi=ctb.game

or client.cgi

www.gamecenter.com/client.cgi?name=dave

Another suggestion, you might use form tags.
For example:

<form action="www.gamecenter.com/index.cgi" method="post">
<input type="submit" name="ctb.game" value="Gamecenter">
</form>

If you go this route, be sure to use the method="post" so the variables do not get passed back in the url as with the "get" method.

mrmick
0
 
lancejAuthor Commented:
Hi,

     I have IIS set up properly.  I have the script type setup as a default.  IIS does call the script regardless of whether I pass a variable or not.

www.domain.com/index.cgi?variable

The above calls the script and QUERY_STRING="variable".

www.domain.com/?variable

The above calls the script and QUERY_STRING=""

I *know* that other people are using the URL form that I want (www.domain.com/?whatever).  I need to know if IIS is unable to do this, or if *I* just don't know how to make it work.

Thanks,
Lance

0
 
case051397Commented:
Hi, Lance,

sorry to, but:
you're right, IIS isn't that smart. What you are
doing is telling IIS this:

"If someone comes to my website www.foo.com, take her
to index.cgi, no matter what the URL is really like."

or - even worse -:

"If someone comes to my website via the default URL
(i.e. http://www.foo.com/), take her to index.cgi."

IIS does exactly what you told it, it just redirects
the browser to index.cgi. Therefore, it cuts of every-
thing after the trailing slash. Only if you supply
the URL that is the default already, IIS keeps the
rest and passes it to the script.

"Smarter" web servers offer a thing called "URL-rewriting",
like apache > 1.1. There you could say:
"make `http://www.foo.com/?fred´ to
      `http://www.foo.com/index.cgi?fred´ or
      `http://www.foo.com/index.cgi?target=fred´"
or whatever. By doing so, you could even do
"make `http://www.foo.com/this/page.html´ to
      `http://www.foo.com/cgi-bin/redir?target=page´"
but IIS won't behave that way. Maybe NT 5 will
come along with that, but maybe not...
0
 
lancejAuthor Commented:
Hi,

I'm satisfied with the comment that "case" has given.  How do I accept his comment as an answer and award the points to him?  I tried selecting "Mark a comment as an answer", but got a 404.

Thanks,
Lance

0
All Courses

From novice to tech pro — start learning today.