Solved

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

Posted on 1997-06-24
9
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Configure Robocopy to excluding folders 6 69
remove computer from using logon script 17 45
Powershell Exchange mailboxsizes 3 47
Where to download python requests library 6 62
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to count occurrences of each item in an array.

763 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