Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 1997-06-24
9
Medium Priority
?
245 Views
Last Modified: 2013-12-25
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

0
Comment
Question by:lancej
9 Comments
 
LVL 1

Expert Comment

by:viro
ID: 1828538
Try this:

www.domain.com?variable


Hope it Help!

Vitor Rodrigues
  Portugal
0
 

Author Comment

by:lancej
ID: 1828539
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
 
LVL 8

Expert Comment

by:mrmick
ID: 1828540
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
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 

Author Comment

by:lancej
ID: 1828541
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
 
LVL 8

Expert Comment

by:mrmick
ID: 1828542
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
 

Author Comment

by:lancej
ID: 1828543
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
 

Expert Comment

by:case051397
ID: 1828544
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
 

Author Comment

by:lancej
ID: 1828545
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
 

Accepted Solution

by:
atticus earned 200 total points
ID: 1828546
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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question