CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Location command in Perl - what's 'wrong' with it?

 



vpendrak
New User

Sep 4, 2009, 11:36 AM

Post #1 of 3 (1678 views)
Location command in Perl - what's 'wrong' with it? Can't Post

Hi,

I'm re-writing a Perl code created by someone else (within a code somecode.cgi) and found something interesting. I came upon a 'Location' command that normally redirects you to a specified page :

print "Location: http://www.yyy.com/temp/index.htm\n\n";

which could be equivalent to:

print "Location: index.htm\n\n";
if the cgi is executed under http://www.yyy.com/temp/

up until now, it is understandable.
My confusion comes when instead of .htm file I used .php extension (a htm version with some php code in it).

Used in the above context, it actually WORKS (executes) as a regular PHP code. On top of that, when a relative path is being used, the address bar in a browser does not show the index.php (htm) file but it stays with an original cgi script that was called. Which makes me question.....is this a normal behavior for Apache to interpret this file as a php (since this is not a web request) and is there any documentation about it?

I'm writing this post because this solution would save a great deal of work for whatever I'm working on but since this is viewed as a bug (on a Apache side) by my manager, it cannot be implemented.

Any help is appreciated.
Thanks


FishMonger
Veteran / Moderator

Sep 4, 2009, 12:52 PM

Post #2 of 3 (1674 views)
Re: [vpendrak] Location command in Perl - what's 'wrong' with it? [In reply to] Can't Post

It's not a bug in Apache. It's a bug in your code.

A redirection request should be a full url which includes the scheme i.e., the protocol such as http:// or https://. You should NOT use relative paths like print "Location: index.htm\n\n"; in a redirection header because it's not fully supported and will give unpredictable results.


Quote
is this a normal behavior for Apache to interpret this file as a php (since this is not a web request)

What do you mean by it's not a web request? You have a cgi script that executes a redirection request/header. That by definition is a web request. Just because it may be requesting a local file, doesn't mean that it's not a web request.


vpendrak
New User

Sep 8, 2009, 9:05 AM

Post #3 of 3 (1616 views)
Re: [FishMonger] Location command in Perl - what's 'wrong' with it? [In reply to] Can't Post

Thanks a lot for your help.

Using a relative path would be a great thing in my case. We have pages that use standard headers and footers that are generated through php. In few cases, the perl script does some calculations and the output needs to incorporate those headers and footers together with the results. It would be ideal to be able to call that index.php with some querystring attached and have all this hidden from a user (if the relative link is used....that's what happens).

Otherwise, would you know of any way where I could use 'Location http://www.zzz.com/index.php' command and pass the values to it but not exposing them (equivalent to POST method) so the url address stays clean.

Thanks
vp

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives