Gossamer Forum
Home : General : Perl Programming :

Is "Location" a reserved word?

Quote Reply
Is "Location" a reserved word?
I've got a script that runs from the command line okay, but when I run it from the brower I get the following error:

"The URL you asked for does not exist on this website."

The offending line is this:
print "Location:" . $SDN_Address . $SDN_City . $SDN_Country . "\n\n";

If I change "Location:" to anything else (example "Locatio:") then the script runs as intended.

I can provide more details if needed. I'll let you know if pulling the script into a proper web page (ie, content-type: html) solves the problem. I'm using Xitami as a personal webserver, btw.

Anyway... this is one of those things that took a bit of trial & error to discover. Argh!

Attached is the whole script I'm currently working on - it's not pretty, but at least I'm using strict Tongue

Any comments/suggestions appreciated (just explain "why" so I can learn).
Quote Reply
Re: [Watts] Is "Location" a reserved word? In reply to
print "Location:..." = location header that redirects client browser. In your case, redirecting to $SDN_Address . $SDN_City . $SDN_Country, which is not a valid URL. You need to change:

print "Location:" . $SDN_Address . $SDN_City . $SDN_Country . "\n\n";

to something like one of the following:

print "-Location:" . $SDN_Address . $SDN_City . $SDN_Country . "\n\n";
print "Location - " . $SDN_Address . $SDN_City . $SDN_Country . "\n\n";
print 'Location:' . $SDN_Address . $SDN_City . $SDN_Country . "\n\n";

or precede with:

print "Content-type: text/html\n\n";

...which should precede 'first' print statement if you are outputting to browser.

----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln
Quote Reply
Re: [dan] Is "Location" a reserved word? In reply to
That's kinda what I figured... thanks for the clarification.