Solved

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

Posted on 1997-06-24
9
213 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 100 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now