PDA

View Full Version : how to exec cgi script like this "http://www.domain.com/?page=home"


tunguru
09-09-2004, 07:11 AM
Alright, I have been trying to I figured this one out for some time. Thought I got it working, but running into a few problems.

I am programming in perl, apache, and the CGI package.

I have seen sites out there that execute their cgi script like this or "http://www.domain.com/?page=login"

I want to execute my "main.cgi" script like this:
"http://www.domain.com/?page=home"
instead of this:
"http://www.domain.com/cgi-bin/main.cgi?page=home"

1. Here's what I've tried to do:
1.1 make "index.shtml" the default DirectoryIndex in the apache config file

1.2 contents of "index.shtml" is one single line:
<!--#exec cgi="/cgi-bin/main.cgi" -->

2. What works:
2.1 http://www.domain.com/?page=home takes me the the home page.
2.2 http://www.domain.com/?page=login takes me the the login page.

3. What does not work:
3.1 Forms cannot be called this way.
For example, I want to call my login form like this
<form method="post" action="../?page=login">

When I call the form this way:
<form method="post" action="../cgi-bin/main.cgi?page=login">
The login form processes correctly. But then the url displays: "http://www.domain.com/cgi-bin/main.cgi", which which is what I do not want.

3.2 Cookies do not get set.
All my pages have the same set cookie header.

When I use "http://www.domain.com/?page=home" the cookie does not get set.

When I use "http://www.domain.com/cgi-bin/main.cgi?page=home", the cookie gets set.

4. So my question is: Am I doing it the right way? Is using <!--#exec cgi="/cgi-bin/main.cgi" --> and putting it in a "index.shtml" the correct way of doing this?

I have a feeling that what I have tried to do is the wrong way,because I have heard that using <!--#exec cgi="*"> tags are dangerous.

Someone please help.