Hi,
I have just created a script that logs the page hit and then serves up the main web page for a site, however when I serve the main page directly from the script all of the relative links become relative to my cgi-bin directory instead of to where the page is originally stored, this affects the images as well, they do not show up because their location is given to the page as a relative address to my cgi-bin.
Any ideas on how to solve this.
I am currently using an intermediate page that redirects automatically to the main page using a meta refresh, but I would really like to intergrate the logging seemlessly into my site so that the user doesn't even realise it has happened.
thanks.
CGI - Page Serving Problem
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:CGI - Page Serving Problem
I wonder why he doesn't execute the script in a kind of hidden or invisible frame or picture. I do this with my php counter script. OK, it outputs the counter to the browser as a png picture.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
Re:CGI - Page Serving Problem
Hi,
The script simply opens a file increments a counter then sevres up a simple page that has a META refresh on it set to 0 timeout so that it immediately redirects to my homepage. So the code is nothing special I just was looking for some ideas.
The reason I do not use it like you do in a picture is because it is used to count how many times a special link is clicked, so I do not want it executed everytime the page is accessed, I only want it executed when a special link to my site is clicked.
thanks for you ideas, I still have not solved the problem though.
thanks again.
The script simply opens a file increments a counter then sevres up a simple page that has a META refresh on it set to 0 timeout so that it immediately redirects to my homepage. So the code is nothing special I just was looking for some ideas.
The reason I do not use it like you do in a picture is because it is used to count how many times a special link is clicked, so I do not want it executed everytime the page is accessed, I only want it executed when a special link to my site is clicked.
thanks for you ideas, I still have not solved the problem though.
thanks again.
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:CGI - Page Serving Problem
is it possible to send a http header to the client via perl? in php, this is done with header(...); you need to send a full url to the browser. Maybe after this the relative links are ok too? i am not sure.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
Re:CGI - Page Serving Problem
Hi,
Thankyou very much, your last post inspired a search term that found exactly what I wanted.
In case anyone else finds this helpful this is the solution, you simply send the location back to the server like this:
print "Location: <URL>\n\n";
replace <URL> with the actual url that you want returned, for example to return this forums main page you would do this:
print "Location: http://www.mega-tokyo.com/forum/\n\n";
The users browser doesn't know the difference and all relative links are left intact.
thanks again.
Thankyou very much, your last post inspired a search term that found exactly what I wanted.
In case anyone else finds this helpful this is the solution, you simply send the location back to the server like this:
print "Location: <URL>\n\n";
replace <URL> with the actual url that you want returned, for example to return this forums main page you would do this:
print "Location: http://www.mega-tokyo.com/forum/\n\n";
The users browser doesn't know the difference and all relative links are left intact.
thanks again.
Re:CGI - Page Serving Problem
Yes use this code:
That will work just fine.
Code: Select all
print "Location: http://www.mega-tokyo.com/forum/\n\n";