
Jasmine
Administrator
/ Moderator
May 19, 2000, 4:16 AM
Post #2 of 2
(185 views)
|
Assuming you can run cgi programs outside of your cgi-bin, you can write a program and toss it into your main www directory (we'll worry about making the program the default page in a bit). Using the $ENV{'QUERY_STRING'}, you can pull information into your script. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> #!/usr/bin/perl my $name = $ENV{'QUERY_STRING'}; print "Content-type: text/html\n\n"; print qq~ <HTML> <BODY> Hello $name! <!-- Whatever html code you want --> </BODY> </HTML>~; </pre><HR></BLOCKQUOTE> Now, onto making your new program the default page (this assumes you're on an Apache server). Let's say you name the program index.cgi, which is commonly listed as one of the filenames that a web server will look for as a directory's default page. If your web server either doesn't look for index.cgi file as a default page, or it doesn't look for index.cgi first, create a file named .htaccess (notice there's nothing in front of the period, and the extension is htaccess) and copy the following line to it: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> DirectoryIndex index.cgi index.shtml index.html index.htm </pre><HR></BLOCKQUOTE> Because the server will look for indexes in the order they're listed in DirectoryIndex, tt's important that index.cgi is first in the list. Save the file (if your text editor tacks on a .txt extension, simply rename it to .htaccess) and upload it to your main www directory in ASCII format. Now you can use whatever.com/?myname because index.cgi is the first page your web server will look for and find when searching for directory index (default) pages. Hope this helps. Good luck!
|